mirror of https://github.com/AMT-Cheif/drift.git
Resolve columns in CREATE TRIGGER declaration (#751)
This commit is contained in:
parent
cd61c5ad16
commit
0d9196dca8
|
@ -1,3 +1,11 @@
|
|||
## 0.10.1
|
||||
|
||||
- Scan identifiers with `[bracket syntax]`
|
||||
- `NumericToken` now contains individual lexemes making up the number
|
||||
- Improve error messages in some scenarios
|
||||
- Fix type inference for binary expressions where the operands have incompatible types
|
||||
- Improve type inference around `NULL`
|
||||
|
||||
## 0.10.0
|
||||
|
||||
- Breaking: Made `RecursiveVisitor.visit`, `visitList` and `visitExcept` an extension on `AstVisitor`.
|
||||
|
|
|
@ -98,6 +98,10 @@ class ColumnResolver extends RecursiveVisitor<void, void> {
|
|||
}
|
||||
|
||||
final scope = e.scope;
|
||||
|
||||
// Add columns of the target table for when and update of clauses
|
||||
scope.availableColumns = table.resolvedColumns;
|
||||
|
||||
if (e.target.introducesNew) {
|
||||
scope.register('new', TableAlias(table, 'new'));
|
||||
}
|
||||
|
@ -260,7 +264,8 @@ class ColumnResolver extends RecursiveVisitor<void, void> {
|
|||
// merge all columns at each position into a CompoundSelectColumn
|
||||
for (var i = 0; i < amount; i++) {
|
||||
final columnsAtThisIndex = [
|
||||
for (var set in columnSets) if (set.length > i) set[i]
|
||||
for (var set in columnSets)
|
||||
if (set.length > i) set[i]
|
||||
];
|
||||
|
||||
resolved.add(CompoundSelectColumn(columnsAtThisIndex));
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
name: sqlparser
|
||||
description: Parses sqlite statements and performs static analysis on them
|
||||
version: 0.10.0
|
||||
version: 0.10.1
|
||||
homepage: https://github.com/simolus3/moor/tree/develop/sqlparser
|
||||
#homepage: https://moor.simonbinder.eu/
|
||||
issue_tracker: https://github.com/simolus3/moor/issues
|
||||
|
|
|
@ -73,6 +73,26 @@ END;
|
|||
''');
|
||||
expect(context.errors, isEmpty);
|
||||
});
|
||||
|
||||
test('can refer to column in UPDATE OF', () {
|
||||
final context = engine.analyze('''
|
||||
CREATE TRIGGER my_trigger BEFORE UPDATE OF content ON DEMO BEGIN
|
||||
SELECT * FROM demo;
|
||||
END;
|
||||
''');
|
||||
|
||||
expect(context.errors, isEmpty);
|
||||
});
|
||||
|
||||
test('can refer to column in UPDATE OF', () {
|
||||
final context = engine.analyze('''
|
||||
CREATE TRIGGER my_trigger BEFORE DELETE ON DEMO WHEN id < 10 BEGIN
|
||||
SELECT * FROM demo;
|
||||
END;
|
||||
''');
|
||||
|
||||
expect(context.errors, isEmpty);
|
||||
});
|
||||
});
|
||||
|
||||
test("DO UPDATE action in upsert can refer to 'exluded'", () {
|
||||
|
|
Loading…
Reference in New Issue