Reduce the minimum width of two horizontal spacers, the one next to the
table drop down box and the one in the SQL log dock. This way the combo
boxes can take up a bit more space when the window is not that big.
We need to call MainWindow::populateTable() when an SQL script was
executed during startup to make sure the latest data is shown. There is
however no need to do so when no SQL script was specified.
Add two buttons to move the currently selected field up or down to allow
changing the field order of a table.
Extend the DBBrowserDB::renameColumn() method to support changing the
position of a field.
Delete the getTableSQL() method in DBBrowserDB. Because we reload and
store the SQL statements for tables after every change to the DB layout
we can just use these strings instead of having an extra function doing
an extra DB query. This simplifies the code a bit and also reduces the
number of SQL statements executed by the application.
Add two new settings to allow changing the font size inside the SQL log
and the SQL editor.
Increase the default font size from 8 to 9 - better a bit too big on
some systems than too small on others.
Also do some restructuring in the MainWindow to avoid duplicate code to
reload settings.
When creating a new database file for an SQL import load the default
SQLite extensions - just like it's done when creating a new database the
normal way.
Merge the renameColumn() and dropColumn() methods. They are just way too
long and complicated but also very similar that it makes no sense to
keep them separated.
This also simplifies the code of renameColumn() a bit while fixing the
trigger/view/index problem in dropColumn().
When reading in the DB layout use our SQL grammar parser to determine
the fields of a table. This simplifies the code a bit and might also
give more detailed information in some situations.
Show a warning and abort the action when trying to set the auto increment
flag on a column with non-integer values in it because SQLite doesn't
allow setting the flag on these columns.
Save views, triggers and indices before deleting the old table in
renameColumn() and try to create them again after renaming the new
table. This is likely to fail and we'd probably need a grammar for these
objects to make the appropriate changes, so in case it does fail this
just prints a warning with some ideas of what to do.
Store the primary key flag(s) inside the sqlb::Field objects instead of
the sqlb::Table object. Technically this doesn't make a lot of sense but
then again it makes things a lot easier for us. So this should fix quite
a few issues in the entire program, especially - again - in
renameColumn(). It also magically fixes createColumn() which had no
chance of guessing which column should be a PK prior to this.
To benefit from these changes the EditTableDialog has changes as well.
- It should now be possible to set and unset PK and AI flags and they
are actually saved.
- Setting the AI flag automatically sets the data type to Integer
because that's the only type SQLite can handle in an autoincrement
field.
- Clicking on the entry in the data type combobox which is currently
selected doesn't update the DB anymore.
This commit also makes some changes to the unit tests to reflect the API
changes made. But it also adds missing quote characters in some
verification strings.
I hope this is a worthy 500th commit - at least it's got a long commit
message...
Fix the updateSchemea() method to also read and save the not null flag
and the default value of each column.
This fixes a problem in renameColumn() which made it "forget" these
values. It is now possible to set the not null flag of multiple columns
in EditTableDialog.
When setting the Not Null flag of a column in an existing table check if
there are rows with NULL values in this column before making any
changes. This avoids an error in renameColumn() caused by the INSERT
INTO ... SELECT ... statement failing. In a next step we could check if
a default value for this column has been specified and use this in these
kind of situations.
Change the approach to count the total number of rows returned by an SQL
query to also support EXPLAIN and PRAGMA statements. These failed before
because you are not allowed to put them into a COUNT query. This commit
adds the code needed to count the number of rows manually when one of
these queries is executed.
Fix a bug in SqliteTableModel that caused the application to crash when
the SQL query contained a semicolon somewhere in the middle of the
string. This was caused by an error in the rtrimChar function which
returned everything left of the first semicolon. The new implementation
only removed trailing characters.
Allow setting the default value, the check values and under some
circumstances the not null flag when editing existing tables.
This required some changes to DBBrowserDB::renameColumn() which is now
using some more features of sqlitetypes.cpp but could still be improved.