Commit Graph

18 Commits

Author SHA1 Message Date
Martin Kleusberg
f2c3c2b1a4 Parse and save foreign key constraints
When parsing a CREATE TABLE statement read and try to parse any foreign
key constraints and save that information.
2014-11-06 18:28:28 +01:00
Peinthor Rene
594ea38420 Fix insert on integer PK fields with not null
Moved the emptyinsertstmt into DBBrowserDB class
to be able to query the database for values.
2014-09-21 20:45:12 +02:00
Martin Kleusberg
b87992c8fb Clean up the DBBrowserDB class a bit 2014-08-31 16:10:01 +02:00
Martin Kleusberg
c7de94cb77 Make it possible to add rows to a WITHOUT rowid table
This commit allows you to add new rows to a table without rowid column.
The main problem here is that SQLite won't create the next value for the
primary key column itself, so we have to do that instead.

See issue #51.
2014-08-26 18:38:04 +02:00
Peinthor Rene
55678bb945 sql: use _rowid_ instead of rowid
This doesn't really solve the problem, but reduces the chance
to have a nameclash with rowid, until we come up with something better
we can't fully support tables with a column name _rowid_ but that should
be very seldom
2014-08-22 23:21:44 +02:00
Peinthor Rene
9aa73915c3 sqliteparsing: add a flag to indicate if we support modifying in our dlg
This flag should indicate if we can fully handle this table definition
in our edit table dialog. if not we should do one of these things:
* disable the edit table dialog to modify the table
* display a warning message that modifying this table may remove constraints
* ??
2014-08-18 19:41:49 +02:00
Peinthor Rene
bd11193235 sqlitetypes: avoid copy of member 2014-08-18 18:40:10 +02:00
Peinthor Rene
f291f89a93 sqlitetypes: extract unique information of columns 2014-08-07 23:14:21 +02:00
Martin Kleusberg
3761acfd02 Extend SQL grammar to recognise 'without rowid' tables correctly
Since version 3.8.2 SQLite supports tables without the internal rowid
column added to the table. For these tables the primary key serves as a
replacement for the rowid column.

These changes update the grammar parser to correctly handle 'without
rowid' tables and also generate 'without rowid' SQL statements.
2014-05-09 14:46:42 +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
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
Peinthor Rene
d08f57c772 add a bit of documentation sqlb::Table::sql() 2013-03-24 21:22:07 +01:00
Peinthor Rene
0d601c03f1 add emptyinsertstm function to table object
creates an empty insert statement for the table fields
2013-03-24 21:20:49 +01:00
Peinthor Rene
f75b361581 add method to easily remove fields from table 2013-03-22 15:51:44 +01:00
Peinthor Rene
1b0d5a2ff9 Fix view updating after remove field in edittable dialog
rename the FieldList typedef to FieldVector
use a object instead of a table pointer in edittable dialog
2013-03-19 17:18:52 +01:00
Peinthor Rene
5737925079 Add a sqlite3 antlr2 "create table" grammar + generated parser files
There is also a "create table" ast walker which fills
info for the new sqlitetype objects.
A dependency to the antlr2 runtime was added.
The grammar most probably still contain bugs.
Why all this?
First writing grammars is fun and this is the only way
we can get all information for proper table editing + some time
in the future when the grammar is finished we can provide real
auto completion.
2013-03-16 20:18:57 +01:00
Peinthor Rene
2920697894 add setter and a datatype list 2013-03-03 22:12:16 +01:00
Peinthor Rene
9394caffa9 add classes for a new sqlite field and table objects
plus a unittest build mode
2013-02-28 17:15:03 +01:00