diff --git a/extras/benchmarks/lib/src/sqlparser/parse_moor_file.dart b/extras/benchmarks/lib/src/sqlparser/parse_moor_file.dart index 5fb8abc5..1e743ef6 100644 --- a/extras/benchmarks/lib/src/sqlparser/parse_moor_file.dart +++ b/extras/benchmarks/lib/src/sqlparser/parse_moor_file.dart @@ -33,7 +33,7 @@ manyColumns: class ParseMoorFile extends BenchmarkBase { ParseMoorFile(ScoreEmitter emitter) : super('Moor file: Parse only', emitter); - final _engine = SqlEngine(useMoorExtensions: true); + final _engine = SqlEngine.withOptions(EngineOptions(useMoorExtensions: true)); @override void exercise() { diff --git a/sqlparser/analysis_options.yaml b/sqlparser/analysis_options.yaml deleted file mode 100644 index a055a3e0..00000000 --- a/sqlparser/analysis_options.yaml +++ /dev/null @@ -1,5 +0,0 @@ -include: ../analysis_options.yaml - -analyzer: - errors: - deprecated_member_use_from_same_package: ignore \ No newline at end of file diff --git a/sqlparser/analysis_options.yaml b/sqlparser/analysis_options.yaml new file mode 120000 index 00000000..c9e0d9fb --- /dev/null +++ b/sqlparser/analysis_options.yaml @@ -0,0 +1 @@ +../analysis_options.yaml \ No newline at end of file diff --git a/sqlparser/lib/src/engine/sql_engine.dart b/sqlparser/lib/src/engine/sql_engine.dart index 9789acac..933ab07b 100644 --- a/sqlparser/lib/src/engine/sql_engine.dart +++ b/sqlparser/lib/src/engine/sql_engine.dart @@ -21,14 +21,19 @@ class SqlEngine { SchemaFromCreateTable _schemaReader; - @Deprecated('Use SqlEngine.withOptions instead') SqlEngine( - {bool useMoorExtensions = false, - bool enableJson1Module = false, - bool enableFts5 = false}) + {@Deprecated('Use SqlEngine.withOptions instead') + bool useMoorExtensions = false, + @Deprecated('Use SqlEngine.withOptions instead') + bool enableJson1Module = false, + @Deprecated('Use SqlEngine.withOptions instead') + bool enableFts5 = false}) : this.withOptions(_constructOptions( + // ignore: deprecated_member_use_from_same_package moor: useMoorExtensions, + // ignore: deprecated_member_use_from_same_package json1: enableJson1Module, + // ignore: deprecated_member_use_from_same_package fts5: enableFts5, )); diff --git a/sqlparser/test/analysis/json_functions_test.dart b/sqlparser/test/analysis/json_functions_test.dart index 86956cc8..3f2f8ce8 100644 --- a/sqlparser/test/analysis/json_functions_test.dart +++ b/sqlparser/test/analysis/json_functions_test.dart @@ -4,7 +4,7 @@ import 'package:test/test.dart'; void main() { group('resolves return types of json functions', () { ResolveResult findResult(String expression) { - final engine = SqlEngine(enableJson1Module: true); + final engine = SqlEngine.withOptions(EngineOptions(enableJson1: true)); final result = engine.analyze('SELECT $expression;'); final select = result.root as SelectStatement; diff --git a/sqlparser/test/analysis/schema/from_create_table_test.dart b/sqlparser/test/analysis/schema/from_create_table_test.dart index b10ed0fe..33fa57e2 100644 --- a/sqlparser/test/analysis/schema/from_create_table_test.dart +++ b/sqlparser/test/analysis/schema/from_create_table_test.dart @@ -63,7 +63,8 @@ void main() { }); test('supports booleans when moor extensions are enabled', () { - final engine = SqlEngine(useMoorExtensions: true); + final engine = + SqlEngine.withOptions(EngineOptions(useMoorExtensions: true)); final stmt = engine.parse(''' CREATE TABLE foo ( a BOOL, b DATETIME, c DATE, d BOOLEAN NOT NULL diff --git a/sqlparser/test/analysis/types/resolver_test.dart b/sqlparser/test/analysis/types/resolver_test.dart index 4f3481a8..8285fa4e 100644 --- a/sqlparser/test/analysis/types/resolver_test.dart +++ b/sqlparser/test/analysis/types/resolver_test.dart @@ -78,7 +78,8 @@ void main() { }); test('can infer types for dart placeholder', () { - final ctx = (SqlEngine(useMoorExtensions: true)..registerTable(demoTable)) + final ctx = (SqlEngine.withOptions(EngineOptions(useMoorExtensions: true)) + ..registerTable(demoTable)) .analyze(r'SELECT * FROM demo WHERE $expr'); final dartExpr = @@ -89,7 +90,8 @@ void main() { }); test('respects explicit types for variables', () { - final ctx = SqlEngine(useMoorExtensions: true).analyze( + final ctx = + SqlEngine.withOptions(EngineOptions(useMoorExtensions: true)).analyze( 'SELECT ?', stmtOptions: const AnalyzeStatementOptions(indexedVariableTypes: { 1: ResolvedType.bool(), diff --git a/sqlparser/test/engine/autocomplete/static_test.dart b/sqlparser/test/engine/autocomplete/static_test.dart index aa895d1a..9b8ca8c5 100644 --- a/sqlparser/test/engine/autocomplete/static_test.dart +++ b/sqlparser/test/engine/autocomplete/static_test.dart @@ -2,9 +2,11 @@ import 'package:sqlparser/sqlparser.dart'; import 'package:sqlparser/src/engine/autocomplete/engine.dart'; import 'package:test/test.dart'; +final _moorOptions = EngineOptions(useMoorExtensions: true); + void main() { test('suggests a CREATE an empty file', () { - final engine = SqlEngine(useMoorExtensions: true); + final engine = SqlEngine.withOptions(_moorOptions); final parseResult = engine.parseMoorFile(''); final suggestions = parseResult.autoCompleteEngine.suggestCompletions(0); @@ -15,7 +17,7 @@ void main() { }); test('suggests CREATE TABLE completion after CREATE', () async { - final engine = SqlEngine(useMoorExtensions: true); + final engine = SqlEngine.withOptions(_moorOptions); final parseResult = engine.parseMoorFile('CREATE '); final suggestions = parseResult.autoCompleteEngine.suggestCompletions(7); @@ -25,7 +27,7 @@ void main() { }); test('suggests completions for started keywords', () { - final engine = SqlEngine(useMoorExtensions: true); + final engine = SqlEngine.withOptions(_moorOptions); final parseResult = engine.parseMoorFile('creat'); final suggestions = parseResult.autoCompleteEngine.suggestCompletions(0); diff --git a/sqlparser/test/engine/module/fts5_test.dart b/sqlparser/test/engine/module/fts5_test.dart index d218891c..04958231 100644 --- a/sqlparser/test/engine/module/fts5_test.dart +++ b/sqlparser/test/engine/module/fts5_test.dart @@ -1,9 +1,11 @@ import 'package:sqlparser/sqlparser.dart'; import 'package:test/test.dart'; +final _fts5Options = EngineOptions(enabledExtensions: const [Fts5Extension()]); + void main() { group('creating fts5 tables', () { - final engine = SqlEngine(enableFts5: true); + final engine = SqlEngine.withOptions(_fts5Options); test('can create fts5 tables', () { final result = engine.analyze('CREATE VIRTUAL TABLE foo USING ' @@ -33,7 +35,7 @@ void main() { group('type inference for function calls', () { SqlEngine engine; setUp(() { - engine = SqlEngine(enableFts5: true); + engine = SqlEngine.withOptions(_fts5Options); // add an fts5 table for the following queries final fts5Result = engine.analyze('CREATE VIRTUAL TABLE foo USING ' 'fts5(bar, baz);'); @@ -77,7 +79,7 @@ void main() { group('type inference for function arguments', () { SqlEngine engine; setUp(() { - engine = SqlEngine(enableFts5: true); + engine = SqlEngine.withOptions(_fts5Options); // add an fts5 table for the following queries final fts5Result = engine.analyze('CREATE VIRTUAL TABLE foo USING ' 'fts5(bar, baz);'); @@ -123,7 +125,7 @@ void main() { group('error reporting', () { SqlEngine engine; setUp(() { - engine = SqlEngine(enableFts5: true); + engine = SqlEngine.withOptions(_fts5Options); // add an fts5 table for the following queries final fts5Result = engine.analyze('CREATE VIRTUAL TABLE foo USING ' 'fts5(bar, baz);'); diff --git a/sqlparser/test/parser/moor_file_test.dart b/sqlparser/test/parser/moor_file_test.dart index 026ae801..52b10da6 100644 --- a/sqlparser/test/parser/moor_file_test.dart +++ b/sqlparser/test/parser/moor_file_test.dart @@ -93,7 +93,7 @@ void main() { test("reports error when the statement can't be parsed", () { // regression test for https://github.com/simolus3/moor/issues/280#issuecomment-570789454 - final parsed = SqlEngine(useMoorExtensions: true) + final parsed = SqlEngine.withOptions(EngineOptions(useMoorExtensions: true)) .parseMoorFile('name: NSERT INTO foo DEFAULT VALUES;'); expect( diff --git a/sqlparser/test/parser/utils.dart b/sqlparser/test/parser/utils.dart index 1ebc12c7..b78a8ab5 100644 --- a/sqlparser/test/parser/utils.dart +++ b/sqlparser/test/parser/utils.dart @@ -19,15 +19,19 @@ IdentifierToken identifier(String content) { } void testMoorFile(String moorFile, MoorFile expected) { - final parsed = - SqlEngine(useMoorExtensions: true).parseMoorFile(moorFile).rootNode; + final parsed = SqlEngine.withOptions(EngineOptions(useMoorExtensions: true)) + .parseMoorFile(moorFile) + .rootNode; enforceHasSpan(parsed); enforceEqual(parsed, expected); } void testStatement(String sql, AstNode expected, {bool moorMode = false}) { - final parsed = SqlEngine(useMoorExtensions: moorMode).parse(sql).rootNode; + final parsed = + SqlEngine.withOptions(EngineOptions(useMoorExtensions: moorMode)) + .parse(sql) + .rootNode; enforceHasSpan(parsed); enforceEqual(parsed, expected); }