Commit Graph

79 Commits

Author SHA1 Message Date
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
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
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
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
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
Martin Kleusberg
23331ea181 DBBrowserDB: Always update internal variables after changing the DB layout
Make sure to always replace the old DB layout representation in
DBBrowserDB after making changes to the database.
2013-05-31 14:12:10 +02:00
Martin Kleusberg
f3ae25572d DBBrowserDB: Remove the dirty flag
Remove the dirty flag as it is no longer needed. Because we track the
savepoints currently held open we can just use that list to see wether
there are changes to be committed. So there is no need to track this in
a separate variable.
2013-05-23 18:16:58 +02:00
Martin Kleusberg
a1b72c5eef Extend the entire savepoint logic to allow multiple active savepoints
Allow multiple savepoints in DBBrowserDB, i.e. setRestorePoint() doesn't
simply return if the DB is already set to dirty but creates an
additional savepoint.

Track the names of all savepoints which have not been either saved or
reverted yet.

Finally, and that's the whole point of this commit, change the savepoint
logic of the EditTableDialog. We used to have a transaction started when
opening a database which was only committed when the file was closed
again. This way the EditFileDialog could savely create a savepoint when
being opened and just release it when OK was clicked or revert to it
when cancel was clicked. Getting rid of the transaction broke this
logic. The dialog still worked but as the savepoint was released when
the changes were applied all changes made via the dialog were
immediately committed to the database. So clicking the revert button had
no effect on those changes. This is at best an unexpected behaviour but
could also be a problem when some changes are reverted while others
aren't. So, having the option now of keeping multiple savepoints opened
this problem can be fixed by just creating a new savepoint every time
the dialog is opened, reverting to it when it is cancelled and _not_
releasing it when OK is clicked.

I hope this works!
2013-05-23 17:41:16 +02:00
Martin Kleusberg
4dfabe4a78 VacuumDialog: Add dialog to allow compacting single objects individually
Add a new dialog which is shown when compacting the database. This
dialog allows selecting single objects individually to avoid vacuuming
the entire database.

It also shows a new warning if the database is dirty as changes are
going to be saved before vacuuming.
2013-05-21 22:32:05 +02:00
Martin Kleusberg
6f8e988f10 Also enable extension loading when creating a new database 2013-05-21 21:01:19 +02:00
Martin Kleusberg
c251a001a1 DBBrowserDB: Fix transaction logic in execute{Multi}SQL
Create a restore point in executeSQL and executeMultiSQL instead of just
setting the dirty flag. This way the changes made using these functions
are not applied immediately when no restore point was created yet.
2013-05-17 14:39:42 +02:00
Martin Kleusberg
5a3658cad2 DBBrowserDB: Show progress dialog in executeMultiSQL()
Show a progress dialog when executing multiple SQL statements. This
mainly affects the SQL import.
2013-05-10 12:58:46 +02:00
Martin Kleusberg
5536c13a06 DBBrowserDB: Export BLOBs correctly
When creating an SQL dump also export BLOB data correctly.
2013-05-09 18:47:32 +02:00
Martin Kleusberg
90d423c66f DBBrowserDB: Don't export sqlite_stat1 table when dumping DB
When creating a SQL dump of the database don't export the sqlite_stat1
table as it's impossible to import it later because SQLite generates it
automatically.
2013-05-09 18:18:18 +02:00
Martin Kleusberg
5b9d5cc40b Remove some debug messages. Change some error messages..
Remove some useless debug messages, e.g. because they just print an SQL
string which you can see in the SQL log window anyway.

Change some "critical" errors messages to just warning. No sense in
printing a critical error message when the program can handle the
problem by itself.
2013-05-08 22:03:04 +02:00
Martin Kleusberg
33d3dcdc16 Fix extension loading 2013-05-03 16:11:35 +02:00
Martin Kleusberg
e36b17a485 Add support for SQLite extension loading
Enable the extension support in SQLite.

Add code to allow loading of extension.

Add menu entry for easy extension loading.
2013-05-03 15:26:34 +02:00
Martin Kleusberg
b9d0497c99 More cleanup in SqliteDB 2013-04-19 20:00:59 +02:00
Martin Kleusberg
b4a64d6208 Clean up SQLiteDB
Much of the code in there is not really needed anymore as quite a bit of
functionality has been moved to the SqliteTableModel.
2013-04-19 19:54:26 +02:00
Martin Kleusberg
1ba3169428 Fix CSV export to work with SqliteTableModel 2013-04-10 18:59:37 +02:00
Martin Kleusberg
f45b89b6c9 Fix SQL export to work with the SqliteTableModel 2013-04-10 18:51:18 +02:00
Martin Kleusberg
31bf07000b SqliteTableModel: Restore BLOB support and clean up DBSQLiteDB 2013-04-10 18:18:08 +02:00
Martin Kleusberg
77cf98fd53 SqliteTableModel: Inserting and deleting rows, clean up, bug fixes
Add some basic code to support inserting and deleting rows again.

Fix a few bugs here and there.

Do some general code clean up.
2013-04-07 19:08:40 +02:00
Martin Kleusberg
5d2139ce99 Kind of fix the find dialog when using the SqliteTableModel 2013-04-06 23:40:47 +02:00
Martin Kleusberg
00b9f40271 SqliteTableModel: Make editing of data possible again 2013-04-06 23:12:53 +02:00
Peinthor Rene
16a40ed349 it's now possible to specify the restore point name 2013-03-28 10:51:09 +01:00
Peinthor Rene
3d6b09ddb4 kill too long lines, no functional changes 2013-03-25 06:15:27 +01:00
Peinthor Rene
7eb385b28d remove the defaultnewdata setting
it is useless now
2013-03-24 21:27:36 +01:00
Peinthor Rene
d7d6a861b2 Rework the kinda broken add record button
Now it should always be possible to add a new record,
no matter how the table is defined or what the new data default is.
The default new data setting will be removed in the next commit.
2013-03-24 21:26:01 +01:00
Peinthor Rene
efef0cc5ac rename createColumn to addColumn
and make it work with the new sqltypes
2013-03-24 13:01:58 +01:00
Peinthor Rene
35449e7c1a rework the dropcolumn function
it now uses the sqlb::Table object preserving:
not null, default value, check constraint
2013-03-22 15:56:07 +01:00
Peinthor Rene
8f6d8213cb replace sqlite3_prepare with _v2 calls
Should be ok for our usage
2013-03-22 06:06:06 +01:00
Martin Kleusberg
0868f299af Rewrite and simplify import SQL code
Rewrite the import SQL code using a similar method to the one used in
executeQuery(). This makes the code much easier to read and removes the
last remnants of that C code stolen from some demo application.
2013-03-20 22:17:36 +01:00
Peinthor Rene
fc6ea39a61 don't put db in dirty mode for nested transactions 2013-03-19 17:18:52 +01:00
Martin Kleusberg
5dcf08b590 Fix leak in DBBrowserDB::updateRecord()
Fix a possible leak of a SQLite statement object in case of an error in
the updateRecord() method. This also preserves the correct error message.
2013-03-18 19:02:11 +01:00
Peinthor Rene
efafe42177 Fix a transaction leak 2013-03-17 22:26:43 +01:00
Martin Kleusberg
725a14c21d DBBrowserDB: Fix bug in updateRecord()
Fix a bug in the updateRecord() method that made it impossible to update
INT columns.
2013-03-17 18:35:08 +01:00
Martin Kleusberg
6c8712d804 Change the internal data type for cell contents to a binary type
Store the data of a DB cell in a QByteArray, i.e. a binary data type,
instead of putting it in a QString, thus converting it to a UTF8 string.

Rewrite the reading and writing of DB cells to correctly handle binary
data containing 0x00 bytes.

Change the edit dialog to actually do all the data checks etc. on a
currently invisible QHexEdit widget instead of a QTextEdit.

All these changes combined make it possible to actually store binary
data without it being corrupted. You can for example import pictures
now, export them and actually open the exported file. So this is an
improvement.
2013-03-17 01:38:48 +01:00
Peinthor Rene
94955c1db9 add a function to return the create table statement for a given table 2013-03-13 18:09:40 +01:00
Peinthor Rene
df91d663f9 Fix the transaction logic 2013-03-05 20:22:17 +01:00
Peinthor Rene
93acb897df fix locking the database by just opening it 2013-03-04 19:25:15 +01:00
Peinthor Rene
d6533747b4 rework database encoding settings and conversions 2013-02-23 13:00:07 +01:00
Peinthor Rene
f8777ca550 add some constness 2013-02-14 18:43:46 +01:00
Peinthor Rene
f8e51cc07a add a foreign key setting
to open database with foreign keys enabled
2013-01-29 18:26:29 +01:00
Peinthor Rene
13792e8100 forgot to add an else branch 2013-01-26 10:25:50 +01:00
Peinthor Rene
c5dafe9617 avoid useless string copies and fix a bug with logSQL because of that 2013-01-26 10:23:04 +01:00