Only use the current analysis steps for CRUD statements

This commit is contained in:
Simon Binder 2019-07-28 21:22:18 +02:00
parent 0bad842735
commit 3a2646e837
No known key found for this signature in database
GPG Key ID: 7891917E4147B8C0
6 changed files with 17 additions and 8 deletions

View File

@ -2,7 +2,7 @@ part of '../ast.dart';
/// A "CREATE TABLE" statement, see https://www.sqlite.org/lang_createtable.html
/// for the individual components.
class CreateTableStatement extends Statement {
class CreateTableStatement extends Statement with SchemaStatement {
final bool ifNotExists;
final String tableName;
final List<ColumnDefinition> columns;

View File

@ -1,6 +1,6 @@
part of '../ast.dart';
class DeleteStatement extends Statement {
class DeleteStatement extends Statement with CrudStatement {
final TableReference from;
final Expression where;

View File

@ -1,6 +1,6 @@
part of '../ast.dart';
class SelectStatement extends Statement with ResultSet {
class SelectStatement extends Statement with CrudStatement, ResultSet {
final bool distinct;
final List<ResultColumn> columns;
final List<Queryable> from;

View File

@ -1,3 +1,9 @@
part of '../ast.dart';
abstract class Statement extends AstNode {}
/// Marker mixin for statements that read from an existing table structure.
mixin CrudStatement on Statement {}
/// Marker mixin for statements that change the table structure.
mixin SchemaStatement on Statement {}

View File

@ -16,7 +16,7 @@ const Map<TokenType, FailureMode> _tokensToMode = {
TokenType.ignore: FailureMode.ignore,
};
class UpdateStatement extends Statement {
class UpdateStatement extends Statement with CrudStatement {
final FailureMode or;
final TableReference table;
final List<SetComponent> set;

View File

@ -57,10 +57,13 @@ class SqlEngine {
try {
ReferenceFinder(globalScope: scope).start(node);
node
..accept(ColumnResolver(context))
..accept(ReferenceResolver(context))
..accept(TypeResolvingVisitor(context));
if (node is CrudStatement) {
node
..accept(ColumnResolver(context))
..accept(ReferenceResolver(context))
..accept(TypeResolvingVisitor(context));
}
} catch (e) {
// todo should we do now? AFAIK, everything that causes an exception
// is added as an error contained in the context.