mirror of https://github.com/AMT-Cheif/drift.git
Report syntax error for WITH in trigger
This commit is contained in:
parent
e2fe4228ad
commit
07fe555753
|
@ -1,3 +1,7 @@
|
|||
## 0.30.1
|
||||
|
||||
- Report syntax error for `WITH` clauses in triggers.
|
||||
|
||||
## 0.30.0
|
||||
|
||||
- Add `previous` and `next` fields for tokens
|
||||
|
|
|
@ -544,4 +544,17 @@ class LintingVisitor extends RecursiveVisitor<void, void> {
|
|||
|
||||
visitChildren(e, arg);
|
||||
}
|
||||
|
||||
@override
|
||||
void visitWithClause(WithClause e, void arg) {
|
||||
if (_isInTopLevelTriggerStatement) {
|
||||
context.reportError(AnalysisError(
|
||||
type: AnalysisErrorType.synctactic,
|
||||
relevantNode: e.withToken ?? e,
|
||||
message: 'WITH clauses cannot appear in triggers.',
|
||||
));
|
||||
}
|
||||
|
||||
visitChildren(e, arg);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -80,6 +80,17 @@ void main() {
|
|||
.expectError('DEFAULT VALUES', type: AnalysisErrorType.synctactic);
|
||||
});
|
||||
|
||||
test('WITH clauses', () {
|
||||
// https://sqlite.org/lang_with.html#limitations_and_caveats
|
||||
engine.analyze('WITH x AS (SELECT 1) SELECT 2').expectNoError();
|
||||
|
||||
engine.analyze('''
|
||||
CREATE TRIGGER tgr AFTER INSERT ON demo BEGIN
|
||||
WITH x AS (SELECT 1) SELECT 2;
|
||||
END;
|
||||
''').expectError('WITH', type: AnalysisErrorType.synctactic);
|
||||
});
|
||||
|
||||
group('aliased source tables', () {
|
||||
test('insert', () {
|
||||
engine.analyze('INSERT INTO demo AS d VALUES (?, ?)').expectNoError();
|
||||
|
|
Loading…
Reference in New Issue