mirror of https://github.com/AMT-Cheif/drift.git
Verify that INTEGER PRIMARY KEY accepts absent values
Verifies that #112 is fixed
This commit is contained in:
parent
397d3f2383
commit
77e444b13b
|
@ -19,6 +19,10 @@ const _createConfig = 'CREATE TABLE IF NOT EXISTS config ('
|
|||
'config_key VARCHAR not null primary key, '
|
||||
'config_value VARCHAR);';
|
||||
|
||||
const _createMyTable = 'CREATE TABLE IF NOT EXISTS mytable ('
|
||||
'someid INTEGER NOT NULL PRIMARY KEY, '
|
||||
'sometext VARCHAR);';
|
||||
|
||||
void main() {
|
||||
// see ../data/tables/tables.moor
|
||||
test('creates tables as specified in .moor files', () async {
|
||||
|
@ -31,6 +35,7 @@ void main() {
|
|||
verify(mockQueryExecutor.call(_createWithDefaults, []));
|
||||
verify(mockQueryExecutor.call(_createWithConstraints, []));
|
||||
verify(mockQueryExecutor.call(_createConfig, []));
|
||||
verify(mockQueryExecutor.call(_createMyTable, []));
|
||||
});
|
||||
|
||||
test('infers primary keys correctly', () async {
|
||||
|
@ -40,4 +45,13 @@ void main() {
|
|||
expect(db.withDefaults.primaryKey, isEmpty);
|
||||
expect(db.config.primaryKey, [db.config.configKey]);
|
||||
});
|
||||
|
||||
test('supports absent values for primary key integers', () async {
|
||||
// regression test for #112: https://github.com/simolus3/moor/issues/112
|
||||
final mock = MockExecutor();
|
||||
final db = CustomTablesDb(mock);
|
||||
|
||||
await db.into(db.mytable).insert(const MytableCompanion());
|
||||
verify(mock.runInsert('INSERT INTO mytable DEFAULT VALUES', []));
|
||||
});
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue