When generating SQL statements properly escape all identifiers, even
those containing backticks which apparently are allowed inside
identifiers in SQLite.
See issue #387.
This suddenly failed on my system and broke the CSV import. Maybe
because of some new version of some software? Either way, the new
version should work anywhere.
This changes the SQL grammar parser so that it parses foreign key
clauses instead of just reading to the end of the clause when
encoutering one. This allows using the information inside the clause
later in a more effective way. However, as of now this isn't used yet.
This commit only attempts to imitate the old behaviour using the new
approach (and might fail doing so, causing new errors...).
Fix the handling of default values in the Edit Table dialog by doing two
things: First, change the sqlb::Field class so that it doesn't put quotes
around any default values no matter what. This breaks for example NULL
default values but also causes invalid syntax if the default value is
already in quotes. Secondly, change the Edit Table dialog itself to
double check if the user should've put quotes around their default value
but hasn't. In this case add them automatically.
See issues #64 and #126.
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.
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
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
* ??
Fix table definitions like this...
CREATE TABLE [player_tech_branches]
(
[from_id] INTEGER NOT NULL REFERENCES [techs](id),
[to_id] INTEGER NOT NULL REFERENCES [techs](id),
UNIQUE ([from_id], [to_id]) PRIMARY KEY ([from_id], [to_id])
)
...where there are multiple keys which are not separated by commas.
This partially fixed EoD's database in issue #63.
Fix handling of multiple primary keys followed by a conflict clause like
in thix table definition:
CREATE TABLE [explore_records]
(
[system_id] INTEGER NOT NULL REFERENCES [star_systems](id),
[player_id] INTEGER NOT NULL REFERENCES [players](id),
PRIMARY KEY ([player_id], [system_id]) ON CONFLICT ABORT
)
This partially fixes EoD's problem in issue #63.
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.
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...
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.
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.