@@ -33,7 +33,7 @@ EditTableDialog::EditTableDialog(DBBrowserDB& db, const QString& tableName, bool
3333 if (m_bNewTable == false )
3434 {
3535 // Existing table, so load and set the current layout
36- m_table = *(pdb.getObjectByName (curTable).dynamicCast <sqlb::Table>());
36+ m_table = *(pdb.getObjectByName (sqlb::ObjectIdentifier ( " main " , curTable) ).dynamicCast <sqlb::Table>());
3737 ui->labelEditWarning ->setVisible (!m_table.fullyParsed ());
3838
3939 // Set without rowid and temporary checkboxex. No need to trigger any events here as we're only loading a table exactly as it is stored by SQLite, so no need
@@ -163,7 +163,7 @@ void EditTableDialog::accept()
163163 // Rename table if necessary
164164 if (ui->editTableName ->text () != curTable)
165165 {
166- if (!pdb.renameTable (curTable, ui->editTableName ->text ()))
166+ if (!pdb.renameTable (" main " , curTable, ui->editTableName ->text ()))
167167 {
168168 QMessageBox::warning (this , QApplication::applicationName (), pdb.lastError ());
169169 return ;
@@ -210,7 +210,7 @@ void EditTableDialog::checkInput()
210210 if (oldTableName == fk->table ()) {
211211 fk->setTable (normTableName);
212212 if (!fksEnabled)
213- pdb.renameColumn (curTable, m_table, f->name (), f, 0 );
213+ pdb.renameColumn (sqlb::ObjectIdentifier ( " main " , curTable) , m_table, f->name (), f, 0 );
214214 }
215215 }
216216 }
@@ -239,7 +239,7 @@ void EditTableDialog::updateTypes()
239239
240240 m_table.fields ().at (index)->setType (type);
241241 if (!m_bNewTable)
242- pdb.renameColumn (curTable, m_table, column, m_table.fields ().at (index));
242+ pdb.renameColumn (sqlb::ObjectIdentifier ( " main " , curTable) , m_table, column, m_table.fields ().at (index));
243243 checkInput ();
244244 }
245245}
@@ -279,7 +279,7 @@ void EditTableDialog::itemChanged(QTreeWidgetItem *item, int column)
279279 if (!m_bNewTable)
280280 {
281281 sqlb::FieldVector pk = m_table.primaryKey ();
282- foreach (const sqlb::ObjectPtr& fkobj, pdb.objMap .values (" table" ))
282+ foreach (const sqlb::ObjectPtr& fkobj, pdb.schemata [ " main " ] .values (" table" ))
283283 {
284284 QList<sqlb::ConstraintPtr> fks = fkobj.dynamicCast <sqlb::Table>()->constraints (sqlb::FieldVector (), sqlb::Constraint::ForeignKeyConstraintType);
285285 foreach (sqlb::ConstraintPtr fkptr, fks)
@@ -352,8 +352,9 @@ void EditTableDialog::itemChanged(QTreeWidgetItem *item, int column)
352352 // we need to check for this case and cancel here. Maybe we can think of some way to modify the INSERT INTO ... SELECT statement
353353 // to at least replace all troublesome NULL values by the default value
354354 SqliteTableModel m (pdb, this );
355- m.setQuery (QString (" SELECT COUNT(%1) FROM %2 WHERE %3 IS NULL;" )
356- .arg (sqlb::escapeIdentifier (pdb.getObjectByName (curTable).dynamicCast <sqlb::Table>()->rowidColumn ()))
355+ m.setQuery (QString (" SELECT COUNT(%1) FROM %2.%3 WHERE %4 IS NULL;" )
356+ .arg (sqlb::escapeIdentifier (pdb.getObjectByName (sqlb::ObjectIdentifier (" main" , curTable)).dynamicCast <sqlb::Table>()->rowidColumn ()))
357+ .arg (sqlb::escapeIdentifier (" main" ))
357358 .arg (sqlb::escapeIdentifier (curTable))
358359 .arg (sqlb::escapeIdentifier (field->name ())));
359360 if (m.data (m.index (0 , 0 )).toInt () > 0 )
@@ -489,7 +490,7 @@ void EditTableDialog::itemChanged(QTreeWidgetItem *item, int column)
489490
490491 if (callRenameColumn)
491492 {
492- if (!pdb.renameColumn (curTable, m_table, oldFieldName, field))
493+ if (!pdb.renameColumn (sqlb::ObjectIdentifier ( " main " , curTable) , m_table, oldFieldName, field))
493494 QMessageBox::warning (this , qApp->applicationName (), tr (" Modifying this column failed. Error returned from database:\n %1" ).arg (pdb.lastError ()));
494495 }
495496 }
@@ -548,7 +549,7 @@ void EditTableDialog::addField()
548549
549550 // Actually add the new column to the table if we're editing an existing table
550551 if (!m_bNewTable)
551- pdb.addColumn (curTable, f);
552+ pdb.addColumn (sqlb::ObjectIdentifier ( " main " , curTable) , f);
552553
553554 checkInput ();
554555}
@@ -576,12 +577,12 @@ void EditTableDialog::removeField()
576577 QString msg = tr (" Are you sure you want to delete the field '%1'?\n All data currently stored in this field will be lost." ).arg (ui->treeWidget ->currentItem ()->text (0 ));
577578 if (QMessageBox::warning (this , QApplication::applicationName (), msg, QMessageBox::Yes | QMessageBox::No, QMessageBox::No) == QMessageBox::Yes)
578579 {
579- if (!pdb.renameColumn (curTable, m_table, ui->treeWidget ->currentItem ()->text (0 ), sqlb::FieldPtr ()))
580+ if (!pdb.renameColumn (sqlb::ObjectIdentifier ( " main " , curTable) , m_table, ui->treeWidget ->currentItem ()->text (0 ), sqlb::FieldPtr ()))
580581 {
581582 QMessageBox::warning (0 , QApplication::applicationName (), pdb.lastError ());
582583 } else {
583584 // relayout
584- m_table = *(pdb.getObjectByName (curTable).dynamicCast <sqlb::Table>());
585+ m_table = *(pdb.getObjectByName (sqlb::ObjectIdentifier ( " main " , curTable) ).dynamicCast <sqlb::Table>());
585586 populateFields ();
586587 }
587588 }
@@ -654,7 +655,7 @@ void EditTableDialog::moveCurrentField(bool down)
654655
655656 // Move the actual column
656657 if (!pdb.renameColumn (
657- curTable,
658+ sqlb::ObjectIdentifier ( " main " , curTable) ,
658659 m_table,
659660 ui->treeWidget ->currentItem ()->text (0 ),
660661 m_table.fields ().at (ui->treeWidget ->indexOfTopLevelItem (ui->treeWidget ->currentItem ())),
@@ -664,7 +665,7 @@ void EditTableDialog::moveCurrentField(bool down)
664665 QMessageBox::warning (0 , QApplication::applicationName (), pdb.lastError ());
665666 } else {
666667 // Reload table SQL
667- m_table = *(pdb.getObjectByName (curTable).dynamicCast <sqlb::Table>());
668+ m_table = *(pdb.getObjectByName (sqlb::ObjectIdentifier ( " main " , curTable) ).dynamicCast <sqlb::Table>());
668669 populateFields ();
669670
670671 // Select old item at new position
@@ -710,7 +711,7 @@ void EditTableDialog::setWithoutRowid(bool without_rowid)
710711 // Update table if we're editing an existing table
711712 if (!m_bNewTable)
712713 {
713- if (!pdb.renameColumn (curTable, m_table, QString (), sqlb::FieldPtr (), 0 ))
714+ if (!pdb.renameColumn (sqlb::ObjectIdentifier ( " main " , curTable) , m_table, QString (), sqlb::FieldPtr (), 0 ))
714715 {
715716 QMessageBox::warning (this , QApplication::applicationName (),
716717 tr (" Setting the rowid column for the table failed. Error message:\n %1" ).arg (pdb.lastError ()));
@@ -729,7 +730,7 @@ void EditTableDialog::setTemporary(bool is_temp)
729730 // Update table if we're editing an existing table
730731 if (!m_bNewTable)
731732 {
732- if (!pdb.renameColumn (curTable, m_table, QString (), sqlb::FieldPtr (), 0 ))
733+ if (!pdb.renameColumn (sqlb::ObjectIdentifier ( " main " , curTable) , m_table, QString (), sqlb::FieldPtr (), 0 ))
733734 {
734735 QMessageBox::warning (this , QApplication::applicationName (),
735736 tr (" Setting the temporary flag for the table failed. Error message:\n %1" ).arg (pdb.lastError ()));
0 commit comments