Commit Graph

539 Commits

Author SHA1 Message Date
Peinthor Rene
11c4cf423a cmake: fix a few warnings and add an option to build unittests 2013-07-11 16:15:51 +02:00
Peinthor Rene
26bb0e1adf split unittest class into header and cpp file 2013-07-11 16:12:45 +02:00
Peinthor Rene
7c411904b9 cmake: initial version of cmake build system files 2013-07-09 23:36:43 +02:00
Martin Kleusberg
2fceab31b7 MainWindow: Reduce minimum width of some spacers
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.
2013-07-01 19:13:32 +02:00
Martin Kleusberg
ed04128a74 Grammar: Support table names in single quotes
Don't fail when parsing a CREATE statement like this:
CREATE TABLE 'test' (id INT);
2013-06-23 22:16:13 +02:00
Martin Kleusberg
a6c30fea0a Don't call populateTable() twice on startup when it's not needed
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.
2013-06-18 20:46:50 +02:00
Martin Kleusberg
b4ce93c6e2 MainWindow: Don't show error message when cancelling extenstion loading
Don't show a file-not-found message box when cancelling the open file
dialog to select a SQLite extension.
2013-06-17 21:43:50 +02:00
Martin Kleusberg
7167129464 EditTableDialog: Add buttons to move a field up and down
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.
2013-06-13 20:37:19 +02:00
Martin Kleusberg
bd169e034f DBBrowserDB: Remove getTableSQL() function
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.
2013-06-13 18:11:18 +02:00
Peinthor Rene
7bf3b87411 Fix incorrect single line comment syntax
Did never check if this syntax was correct,
now it should be fine see:
http://www.sqlite.org/lang_comment.html
2013-06-13 06:52:46 +02:00
Martin Kleusberg
1287a2cf6f MainWindow: Further simplification
Looking at this now this can be simplified even further.
2013-06-12 20:22:07 +02:00
Martin Kleusberg
8947579590 MainWindow: Remove unneeded code in fileExit()
There is no need to check for changes when exiting and showing a message
box in the main window as exactly the same code is also run in
DBBrowserDB.
2013-06-12 20:18:51 +02:00
Martin Kleusberg
66e41a1846 CreateIndexDialog: Minor code simplification 2013-06-12 20:12:39 +02:00
Martin Kleusberg
b16c26f022 Readme: Fix headline size 2013-06-12 20:03:51 +02:00
MKleusberg
4589dda134 Merge pull request #29 from justinclift/typo_fix
MainWindow: Typo fix in help tooltip
2013-06-08 15:45:27 -07:00
MKleusberg
3b0efd8769 Merge pull request #28 from justinclift/we_don_need_no_steeeenkin_embedded_tabz
Converted another embedded tab to space.
2013-06-08 15:44:19 -07:00
Justin Clift
da3e356bd8 Typo fix in help tooltip 2013-06-08 20:11:38 +01:00
Justin Clift
af4dcbfa07 Converted another embedded tab to space.
Missed this one. :(
2013-06-08 20:01:59 +01:00
Peinthor Rene
0f37137a0a Merge pull request #27 from justinclift/we_don_need_no_steeeenkin_embedded_tabz
Convert the embedded tabs to spaces
2013-06-08 11:58:26 -07:00
Justin Clift
4b45f040ac Convert the embedded tabs to spaces
For the benefit of people who's editors show embedded tabs visually
as errors (like me). :)
2013-06-08 19:54:55 +01:00
Peinthor Rene
d6552ce7bf Merge pull request #26 from justinclift/osx_include_paths
Added include paths for SQLite3 installed using OSX Homebrew
2013-06-08 11:47:25 -07:00
Justin Clift
c83bf8fcb8 Added include paths for SQLite3 installed using OSX Homebrew 2013-06-08 19:42:05 +01:00
MKleusberg
141cfd5df2 Merge pull request #25 from justinclift/osx_build_instructions
Added initial working OSX build instructions
2013-06-08 03:23:13 -07:00
MKleusberg
b7725841a6 Merge pull request #24 from justinclift/macfixv2
Improved resilience when checking for SQLite on OSX
2013-06-08 03:22:56 -07:00
Justin Clift
31223a0d49 Added initial working OSX build instructions 2013-06-08 01:08:25 +01:00
Justin Clift
8db087a8fb Improved resilience when checking for SQLite on OSX 2013-06-08 00:16:04 +01:00
MKleusberg
487f8adbb1 Merge pull request #22 from justinclift/macpathfix
Update OSX build to use Homebrew compiled libs
2013-06-07 12:03:39 -07:00
Martin Kleusberg
7a81189d50 PreferencesDialog: New settings for font size of SQL editor and log
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.
2013-06-07 20:57:58 +02:00
Justin Clift
8d9044500d Update OSX build to use Homebrew compiled libs 2013-06-07 13:05:39 +01:00
Peinthor Rene
34887e42bf add a fallback gen_version.h if for some reason the creation of the file fails 2013-06-06 09:36:51 +02:00
Martin Kleusberg
720ef9bc95 Also load SQLite extensions when importing a SQL file into a new DB
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.
2013-06-05 21:23:48 +02:00
Martin Kleusberg
d7c9585982 DBBrowserDB: Don't export sqlite_sequence table
When creating an SQL dump don't export the sqlite_sequence table as it
is created internally by SQLite and it is not possible to import it
again.
2013-06-04 22:15:15 +02:00
Martin Kleusberg
324bb23193 DBBrowserDB: Merge renameColumn() and dropColumn()
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().
2013-06-04 17:36:14 +02:00
Martin Kleusberg
2463116976 DBBrowserDB: Use SQL grammar for getting fields of table
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.
2013-06-04 17:13:27 +02:00
Martin Kleusberg
b07f0a5add DBBrowserDB: Clean up logSQL() method 2013-06-04 17:03:57 +02:00
Martin Kleusberg
eb560e2a62 EditTableDialog: Warn when trying to set AI flag on non-integer column
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.
2013-06-04 16:58:54 +02:00
Martin Kleusberg
db39e3e293 DBBrowserDB: Attempt to restore views, indices etc. in renameColumn()
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.
2013-06-04 16:42:31 +02:00
Martin Kleusberg
6bd114dca3 Merge branch 'feature-nologtruncate' of https://github.com/oysteinkrog/sqlitebrowser into oysteinkrog-feature-nologtruncate 2013-06-04 15:13:19 +02:00
Øystein Krog
da0ac6bc0d Don't truncate log messages unless they contain binary data (removes previous log limit of 300 characters)
Adapted from c4d253287f
2013-06-04 10:18:07 +02:00
Martin Kleusberg
63cf871017 SqliteTypes: Move PK flag from table to field
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...
2013-06-03 20:15:29 +02:00
Martin Kleusberg
3a85d96a6d DBBrowserDB: When reading DB layout also save not null and default value
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.
2013-06-03 18:26:46 +02:00
Martin Kleusberg
26faa9c0fb EditTableDialog: Check before setting NN when editing existing table
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.
2013-06-02 21:50:25 +02:00
Martin Kleusberg
928a957e70 SqliteTypes: Allow non-numeric default values
Fix the sqlb::Field class to support non-numeric default values by
putting them in quotes.
2013-06-02 17:16:35 +02:00
Martin Kleusberg
13c3963651 SqliteTableModel: Support EXPLAIN and PRAGMA queries again
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.
2013-06-01 14:41:25 +02:00
Martin Kleusberg
40f8a28fad SqliteTableModel: Don't crash when query contains ';'
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.
2013-06-01 12:58:07 +02:00
Martin Kleusberg
ebadc180ce EditTableDialog: Remove unused function 2013-06-01 12:50:19 +02:00
Martin Kleusberg
fa2589c829 DBBrowserDB: Use sqlb::Field for createTable()
When creating a new table specify the table structure using the
sqlb::Field type instead of just a plain string list.
2013-06-01 12:43:43 +02:00
Martin Kleusberg
c0b3506ede EditTableDialog: Fix bug when renaming column
Store the old column name to be able to address it by its current name
when renameColumn is called.
2013-06-01 12:42:36 +02:00
Martin Kleusberg
cbd81de88b Remove the DBBrowserField class
Remove the DBBrowserField class and change all parts of the program
which used to use this class to work with sqlb::Field instead.
2013-05-31 16:50:13 +02:00
Martin Kleusberg
b9afbe2aea EditTableDialog: Allow some more changes to existing tables
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.
2013-05-31 16:13:58 +02:00