Commit Graph

32 Commits

Author SHA1 Message Date
Martin Kleusberg
d98338ce89 Move all foreign key handling form the fields to the tables
Foreign keys used to be stored along with the column information even
though it's more or less a table constraint. However, as we only support
single column foreign keys it was easier to store it inside that single
column. Now with multi-column foreign keys coming, a mechanism has been
introduced to store those multi-column foreign keys in the table data.
This lead to two different storing places for foreign key information:
inside the field for one-column foreign keys and inside the table for
multi-column foreign keys. This commit deletes the foreign key storage
inside fields and changes all code to use the table storage.
2016-08-19 20:01:25 +02:00
Martin Kleusberg
beff43acfc tests: Add test case for unique table constraints 2016-08-18 20:44:12 +02:00
Martin Kleusberg
7e0adabd6a Fix primary key names not being escaped
See issue #613.
2016-05-27 22:32:53 +02:00
Martin Kleusberg
0e18e36aa9 Parse foreign key clauses instead of just treating them as a big string
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...).
2015-06-21 22:09:36 +02:00
Pino Toscano
27df9cfa4d tests: split sqlb-unittests
Instead of a single executable running different unit tests at the
same time, split the sqlobjects and import parts out of it.
While this currently duplicates the cmake boilerplate for each,
it allows to finetune each properly (like build only the sources for
it, in the future), and to call each separately.

Add the QTEST_MAIN in each test, and remove the manual QCoreApplication
handling in TestImport (handled by QTEST_MAIN).
2015-05-03 14:34:09 +02:00
Martin Kleusberg
a090875575 tests: Add test for grammar fix in 1ea67c33d2 2015-01-06 14:12:08 +01:00
Martin Kleusberg
4b7766a0fe tests: Add tests for foreign key parsing 2014-11-06 18:29:34 +01:00
Martin Kleusberg
19baeb2a7a grammar: Fix double quote characters as used for escaping one
SQL allows you to use two quote characters instead of just one in order
to escape them. Example: ['aa''bb'] is read as [aa'bb]. Add detection
for these doubled quote characters to our grammar parser.

See issue #128.
2014-10-15 19:29:19 +02:00
Martin Kleusberg
b841025bae tests: Add test to check escaping quotes by using two of them 2014-10-15 12:57:37 +02:00
Sandro Mani
27b6bef37d Fix bad test 2014-08-27 19:04:38 +02:00
Sandro Mani
6b4d079e6a Fix syntax issues 2014-08-27 19:04:35 +02:00
Martin Kleusberg
e7924f3739 Tests: Add unit tests for CSV import
Add a new test class for testing the import functionality. Currently
it's only covers some test cases for the CSV import.

Since the function to test here (DBBrowserDB::decodeCSV) is part of the
DBBrowserDB class, that class has a reference to the main window and the
main window basically depends on the entire rest of the project the
makefile grew quite a bit unfortunately.
2014-07-11 21:31:34 +02:00
Martin Kleusberg
ceb74a8cd4 Tests: Make sure the TestTable::parseSQLdefaultexpr() passes
Fix some issues in the parseSQLdefaultexpr unit test to make it actuall
pass.
2014-07-10 21:38:35 +02:00
Peinthor Rene
0df6148afe unittest: add test for literalvalue in default constraint 2014-07-10 07:30:25 +02:00
Peinthor Rene
f2658958ce unittest: add a check for not exists 2014-07-05 15:16:16 +02:00
Peinthor Rene
e1ea78fdda grammar: add tests for like operator and between 2014-06-25 19:20:58 +02:00
Martin Kleusberg
3da0d36463 Tests: Make sure all unit tests pass
Two unit tests where failing because of missing spaces in the expected
result string.
2014-06-20 12:51:56 +02:00
Martin Kleusberg
980f42d200 Tests: Add unit test for CHECK NOT LIKE constraint
Add a unit test for the grammar fix in
9cb0614ecf.
2014-06-20 12:50:30 +02:00
Peinthor Rene
f246ddde1e correctly extract check expression from AST 2014-06-11 22:48:51 +02:00
Peinthor Rene
55d8c9f9d8 add a test with create table with IN 2014-06-11 22:48:51 +02:00
Martin Kleusberg
1f8686d1d4 Add tests for the new 'without rowid' parsing
Add tests for the 'without rowid' parsing in our SQL grammar added in
commit 3761acfd02.
2014-05-09 14:49:32 +02:00
Peinthor Rene
192ee9c0a8 add unittest for non ascii characters 2014-02-12 19:15:27 +01:00
Peinthor Rene
9214cfbc21 add a unittest for the keyword in column name issue 2013-11-24 10:26:32 +01:00
Martin Kleusberg
b924859392 Tests: Add test for ed04128a74
Add a test for table and column names in single quotes for which support
was added in ed04128a74.
2013-07-18 20:45:27 +02:00
Peinthor Rene
1bef2501c0 tests: make this statement work in sqlite3 2013-07-18 15:42:33 +02:00
Peinthor Rene
26bb0e1adf split unittest class into header and cpp file 2013-07-11 16:12:45 +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
a95d33e5ee add unittest for foreign key parser problem 2013-05-03 21:12:56 +02:00
Peinthor Rene
f4187521ee improve the unittests for create table parsing 2013-03-22 15:50:26 +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
9394caffa9 add classes for a new sqlite field and table objects
plus a unittest build mode
2013-02-28 17:15:03 +01:00