mirror of https://github.com/AMT-Cheif/drift.git
New test cases
This commit is contained in:
parent
5380a18450
commit
3c75fbee9d
|
@ -160,7 +160,11 @@ void main() {
|
|||
c TEXT
|
||||
);
|
||||
|
||||
query: SELECT a, LIST(SELECT b, c FROM tbl WHERE a = :a AND b = :b) FROM tbl WHERE a = :a;
|
||||
query:
|
||||
SELECT
|
||||
parent.a,
|
||||
LIST(SELECT b, c FROM tbl WHERE a = :a OR a = parent.a AND b = :b)
|
||||
FROM tbl AS parent WHERE parent.a = :a;
|
||||
''',
|
||||
});
|
||||
});
|
||||
|
@ -204,17 +208,32 @@ void main() {
|
|||
);
|
||||
});
|
||||
|
||||
test('with the new query generator', () {
|
||||
test('should generate correct queries with variables', () {
|
||||
return _runTest(
|
||||
const MoorOptions.defaults(newSqlCodeGeneration: true),
|
||||
[
|
||||
contains('SELECT a FROM tbl WHERE a = ?1'),
|
||||
contains('SELECT b, c FROM tbl WHERE a = ?1 AND b = ?2'),
|
||||
contains('nestedQuery0: await'),
|
||||
contains('variables: [Variable<String?>(a), Variable<String?>(b)]'),
|
||||
contains('b: row.read<String?>(\'b\')'),
|
||||
contains('c: row.read<String?>(\'c\')'),
|
||||
contains('class QueryNestedQuery0'),
|
||||
contains(
|
||||
r'SELECT parent.a, parent.a AS "\$n_0" FROM tbl AS parent WHERE parent.a = ?1',
|
||||
),
|
||||
contains(
|
||||
r'[Variable<String?>(a)]',
|
||||
),
|
||||
contains(
|
||||
r'SELECT b, c FROM tbl WHERE a = ?1 OR a = ?2 AND b = ?3',
|
||||
),
|
||||
contains(
|
||||
r"[Variable<String?>(a), Variable<String>(row.read('\$n_0')), Variable<String?>(b)]",
|
||||
),
|
||||
],
|
||||
);
|
||||
});
|
||||
|
||||
test('should generate correct data class', () {
|
||||
return _runTest(
|
||||
const MoorOptions.defaults(newSqlCodeGeneration: true),
|
||||
[
|
||||
contains('QueryNestedQuery0({this.b,this.c,})'),
|
||||
contains('QueryResult({this.a,required this.nestedQuery0,})'),
|
||||
],
|
||||
);
|
||||
});
|
||||
|
|
|
@ -304,6 +304,10 @@ CREATE UNIQUE INDEX my_idx ON t1 (c1, c2, c3) WHERE c1 < c3;
|
|||
testFormat('INSERT INTO foo DEFAULT VALUES RETURNING *');
|
||||
});
|
||||
|
||||
test('with returning and insert mode', () {
|
||||
testFormat('INSERT OR IGNORE INTO foo DEFAULT VALUES RETURNING *');
|
||||
});
|
||||
|
||||
test('upsert - do nothing', () {
|
||||
testFormat(
|
||||
'INSERT OR REPLACE INTO foo DEFAULT VALUES ON CONFLICT DO NOTHING');
|
||||
|
|
Loading…
Reference in New Issue