diff --git a/README.md b/README.md index ac9e834b..fbd14972 100644 --- a/README.md +++ b/README.md @@ -84,7 +84,7 @@ class MyDatabase { ``` __⚠️ Warning:__ Even though it might look like it, the content of a `Table` class does not support full Dart code. It can only -be used to declare the table name, it's primary keys and columns. The code inside of a table class will never be +be used to declare the table name, its primary key and columns. The code inside of a table class will never be executed. Instead, the generator will take a look at your table classes to figure out how their structure looks like. This won't work if the body of your tables is not constant. This should not be problem, but please be aware of this as you can't put logic inside these classes. @@ -260,4 +260,4 @@ Implementing this will very likely result in backwards-incompatible changes. accessible for the generated code - `GROUP BY` grouping functions - Support for different database engines - - Support webapps via `AlaSQL` or a different engine \ No newline at end of file + - Support webapps via `AlaSQL` or a different engine diff --git a/end_to_end_testing/.gitignore b/end_to_end_testing/.gitignore deleted file mode 100644 index 50602ac6..00000000 --- a/end_to_end_testing/.gitignore +++ /dev/null @@ -1,11 +0,0 @@ -# Files and directories created by pub -.dart_tool/ -.packages -# Remove the following pattern if you wish to check in your lock file -pubspec.lock - -# Conventional directory for build outputs -build/ - -# Directory created by dartdoc -doc/api/ diff --git a/end_to_end_testing/analysis_options.yaml b/end_to_end_testing/analysis_options.yaml deleted file mode 120000 index c9e0d9fb..00000000 --- a/end_to_end_testing/analysis_options.yaml +++ /dev/null @@ -1 +0,0 @@ -../analysis_options.yaml \ No newline at end of file diff --git a/end_to_end_testing/lib/tables.dart b/end_to_end_testing/lib/tables.dart deleted file mode 100644 index 7d80b555..00000000 --- a/end_to_end_testing/lib/tables.dart +++ /dev/null @@ -1,20 +0,0 @@ -import 'package:sally/sally.dart'; - -part 'tables.g.dart'; - -class Users extends Table { - - IntColumn get id => integer().autoIncrement()(); - TextColumn get userName => text().named('name').withLength(min: 6, max: 12)(); - TextColumn get bio => text()(); - -} - -@UseSally(tables: [Users]) -class ExampleDb extends _$ExampleDb { - ExampleDb(QueryExecutor e) : super(e); - @override - MigrationStrategy get migration => MigrationStrategy(); - @override - int get schemaVersion => 1; -} \ No newline at end of file diff --git a/end_to_end_testing/lib/tables.g.dart b/end_to_end_testing/lib/tables.g.dart deleted file mode 100644 index 16fd1a0b..00000000 --- a/end_to_end_testing/lib/tables.g.dart +++ /dev/null @@ -1,87 +0,0 @@ -// GENERATED CODE - DO NOT MODIFY BY HAND - -part of 'tables.dart'; - -// ************************************************************************** -// SallyGenerator -// ************************************************************************** - -class User { - final int id; - final String userName; - final String bio; - User({this.id, this.userName, this.bio}); - @override - int get hashCode => - ((id.hashCode) * 31 + userName.hashCode) * 31 + bio.hashCode; - @override - bool operator ==(other) => - identical(this, other) || - (other is User && - other.id == id && - other.userName == userName && - other.bio == bio); -} - -class _$UsersTable extends Users implements TableInfo { - final GeneratedDatabase _db; - _$UsersTable(this._db); - @override - GeneratedIntColumn get id => - GeneratedIntColumn('id', false, hasAutoIncrement: true); - @override - GeneratedTextColumn get userName => GeneratedTextColumn( - 'name', - false, - ); - @override - GeneratedTextColumn get bio => GeneratedTextColumn( - 'bio', - false, - ); - @override - List get $columns => [id, userName, bio]; - @override - Users get asDslTable => this; - @override - String get $tableName => 'users'; - @override - void validateIntegrity(User instance, bool isInserting) => - id.isAcceptableValue(instance.id, isInserting) && - userName.isAcceptableValue(instance.userName, isInserting) && - bio.isAcceptableValue(instance.bio, isInserting); - @override - Set get $primaryKey => Set(); - @override - User map(Map data) { - final intType = _db.typeSystem.forDartType(); - final stringType = _db.typeSystem.forDartType(); - return User( - id: intType.mapFromDatabaseResponse(data['id']), - userName: stringType.mapFromDatabaseResponse(data['name']), - bio: stringType.mapFromDatabaseResponse(data['bio']), - ); - } - - @override - Map entityToSql(User d) { - final map = {}; - if (d.id != null) { - map['id'] = Variable(d.id); - } - if (d.userName != null) { - map['name'] = Variable(d.userName); - } - if (d.bio != null) { - map['bio'] = Variable(d.bio); - } - return map; - } -} - -abstract class _$ExampleDb extends GeneratedDatabase { - _$ExampleDb(QueryExecutor e) : super(const SqlTypeSystem.withDefaults(), e); - _$UsersTable get users => _$UsersTable(this); - @override - List get allTables => [users]; -} diff --git a/end_to_end_testing/lib/vm_database.dart b/end_to_end_testing/lib/vm_database.dart deleted file mode 100644 index cbd65228..00000000 --- a/end_to_end_testing/lib/vm_database.dart +++ /dev/null @@ -1,42 +0,0 @@ -import 'package:sally/sally.dart'; -import 'package:sqlite2/sqlite.dart'; - -class MemoryDatabase extends QueryExecutor { - Database _db; - - @override - Future ensureOpen() { - _db ??= Database.inMemory(); - return Future.value(true); - } - - @override - Future runCustom(String statement) { - return _db.execute(statement); - } - - @override - Future runDelete(String statement, List args) { - return _db.execute(statement, - params: args.map((x) => x.toString()).toList()); - } - - @override - Future runInsert(String statement, List args) { - return runDelete(statement, args); - } - - @override - Future>> runSelect(String statement, List args) { - return _db - .query(statement, params: args.map((x) => x.toString()).toList()) - .fold([], (list, row) { - return list..add(row.toMap()); - }); - } - - @override - Future runUpdate(String statement, List args) { - return runDelete(statement, args); - } -} diff --git a/end_to_end_testing/pubspec.yaml b/end_to_end_testing/pubspec.yaml deleted file mode 100644 index de634aad..00000000 --- a/end_to_end_testing/pubspec.yaml +++ /dev/null @@ -1,19 +0,0 @@ -name: end_to_end_testing -description: A project to test sally. - -environment: - sdk: '>=2.0.0 <3.0.0' - -dependencies: - sally: - path: ../sally - sqlite2: ^0.5.0 - path: ^1.4.1 - -dev_dependencies: - sally_generator: - path: ../sally_generator - built_value_generator: ^6.3.0 - build_runner: - build_test: - test: ^1.0.0 \ No newline at end of file diff --git a/end_to_end_testing/test/create_tables_test.dart b/end_to_end_testing/test/create_tables_test.dart deleted file mode 100644 index d83d6340..00000000 --- a/end_to_end_testing/test/create_tables_test.dart +++ /dev/null @@ -1,11 +0,0 @@ -import 'package:end_to_end_testing/tables.dart'; -import 'package:end_to_end_testing/vm_database.dart'; -import 'package:test_api/test_api.dart'; - -void main() { - test('Generates tables', () async* { - final db = ExampleDb(MemoryDatabase()); - - await db.handleDatabaseCreation(executor: db.executor.runCustom); - }); -} \ No newline at end of file diff --git a/sally/lib/src/runtime/migration.dart b/sally/lib/src/runtime/migration.dart index 8e96a7f1..4375dcac 100644 --- a/sally/lib/src/runtime/migration.dart +++ b/sally/lib/src/runtime/migration.dart @@ -1,3 +1,5 @@ +import 'dart:async'; + import 'package:sally/sally.dart'; import 'package:sally/src/runtime/structure/columns.dart'; import 'package:sally/src/runtime/structure/table_info.dart'; diff --git a/sally/lib/src/runtime/statements/delete.dart b/sally/lib/src/runtime/statements/delete.dart index d5f63af0..49397ffd 100644 --- a/sally/lib/src/runtime/statements/delete.dart +++ b/sally/lib/src/runtime/statements/delete.dart @@ -1,3 +1,5 @@ +import 'dart:async'; + import 'package:sally/src/runtime/components/component.dart'; import 'package:sally/src/runtime/executor/executor.dart'; import 'package:sally/src/runtime/statements/query.dart'; diff --git a/sally/lib/src/runtime/statements/insert.dart b/sally/lib/src/runtime/statements/insert.dart index 7ac1c668..5f1cf858 100644 --- a/sally/lib/src/runtime/statements/insert.dart +++ b/sally/lib/src/runtime/statements/insert.dart @@ -1,3 +1,5 @@ +import 'dart:async'; + import 'package:meta/meta.dart'; import 'package:sally/sally.dart'; import 'package:sally/src/runtime/components/component.dart'; diff --git a/sally/lib/src/runtime/statements/select.dart b/sally/lib/src/runtime/statements/select.dart index d5037821..deea10d0 100644 --- a/sally/lib/src/runtime/statements/select.dart +++ b/sally/lib/src/runtime/statements/select.dart @@ -1,3 +1,5 @@ +import 'dart:async'; + import 'package:sally/sally.dart'; import 'package:sally/src/runtime/components/component.dart'; import 'package:sally/src/runtime/components/limit.dart'; diff --git a/sally/lib/src/runtime/statements/update.dart b/sally/lib/src/runtime/statements/update.dart index bf5d5abd..f05a5a3c 100644 --- a/sally/lib/src/runtime/statements/update.dart +++ b/sally/lib/src/runtime/statements/update.dart @@ -1,3 +1,5 @@ +import 'dart:async'; + import 'package:sally/sally.dart'; import 'package:sally/src/runtime/components/component.dart'; diff --git a/sally/test/delete_test.dart b/sally/test/delete_test.dart index bc16fbd0..7a5ec439 100644 --- a/sally/test/delete_test.dart +++ b/sally/test/delete_test.dart @@ -1,3 +1,5 @@ +import 'dart:async'; + import 'package:sally/sally.dart'; import 'package:test_api/test_api.dart'; diff --git a/sally/test/select_test.dart b/sally/test/select_test.dart index 464fa3e7..cb2878ac 100644 --- a/sally/test/select_test.dart +++ b/sally/test/select_test.dart @@ -1,3 +1,5 @@ +import 'dart:async'; + import 'package:sally/sally.dart'; import 'package:test_api/test_api.dart'; diff --git a/sally/test/update_test.dart b/sally/test/update_test.dart index 8c6103dc..771538d2 100644 --- a/sally/test/update_test.dart +++ b/sally/test/update_test.dart @@ -1,3 +1,5 @@ +import 'dart:async'; + import 'package:sally/sally.dart'; import 'package:test_api/test_api.dart'; diff --git a/sally_flutter/README.md b/sally_flutter/README.md index 6bf9a3da..fbd14972 100644 --- a/sally_flutter/README.md +++ b/sally_flutter/README.md @@ -84,7 +84,7 @@ class MyDatabase { ``` __⚠️ Warning:__ Even though it might look like it, the content of a `Table` class does not support full Dart code. It can only -be used to declare the table name, it's primary keys and columns. The code inside of a table class will never be +be used to declare the table name, its primary key and columns. The code inside of a table class will never be executed. Instead, the generator will take a look at your table classes to figure out how their structure looks like. This won't work if the body of your tables is not constant. This should not be problem, but please be aware of this as you can't put logic inside these classes. diff --git a/sally_flutter/example/lib/database.dart b/sally_flutter/example/lib/database.dart index 768b1243..20aa661a 100644 --- a/sally_flutter/example/lib/database.dart +++ b/sally_flutter/example/lib/database.dart @@ -32,16 +32,13 @@ class Database extends _$Database { int get schemaVersion => 1; @override - MigrationStrategy get migration => MigrationStrategy( - onCreate: (Migrator m) { - return m.createAllTables(); - }, - onUpgrade: (Migrator m, int from, int to) async { - if (from == 1) { - await m.addColumn(todos, todos.targetDate); - } - } - ); + MigrationStrategy get migration => MigrationStrategy(onCreate: (Migrator m) { + return m.createAllTables(); + }, onUpgrade: (Migrator m, int from, int to) async { + if (from == 1) { + await m.addColumn(todos, todos.targetDate); + } + }); Stream> allEntries() { return select(todos).watch(); diff --git a/sally_flutter/example/lib/main.dart b/sally_flutter/example/lib/main.dart index a918c81c..17d11043 100644 --- a/sally_flutter/example/lib/main.dart +++ b/sally_flutter/example/lib/main.dart @@ -12,7 +12,6 @@ class MyApp extends StatefulWidget { } class MyAppState extends State { - Database _db; @override @@ -37,7 +36,6 @@ class MyAppState extends State { } class DatabaseProvider extends InheritedWidget { - final Database db; DatabaseProvider({@required this.db, Widget child}) : super(child: child); @@ -47,5 +45,7 @@ class DatabaseProvider extends InheritedWidget { return oldWidget.db != db; } - static Database provideDb(BuildContext ctx) => (ctx.inheritFromWidgetOfExactType(DatabaseProvider) as DatabaseProvider).db; -} \ No newline at end of file + static Database provideDb(BuildContext ctx) => + (ctx.inheritFromWidgetOfExactType(DatabaseProvider) as DatabaseProvider) + .db; +} diff --git a/sally_flutter/example/lib/widgets/todo_card.dart b/sally_flutter/example/lib/widgets/todo_card.dart index bf4e101e..a309d107 100644 --- a/sally_flutter/example/lib/widgets/todo_card.dart +++ b/sally_flutter/example/lib/widgets/todo_card.dart @@ -3,7 +3,6 @@ import 'package:sally_example/database.dart'; import 'package:sally_example/main.dart'; class TodoCard extends StatelessWidget { - final TodoEntry entry; TodoCard(this.entry) : super(key: ObjectKey(entry.id)); diff --git a/sally_flutter/lib/src/animated_list.dart b/sally_flutter/lib/src/animated_list.dart index 1d2516f0..208be356 100644 --- a/sally_flutter/lib/src/animated_list.dart +++ b/sally_flutter/lib/src/animated_list.dart @@ -3,17 +3,21 @@ import 'dart:async'; import 'package:flutter/widgets.dart'; import 'package:sally/diff_util.dart'; -typedef Widget ItemBuilder(BuildContext context, T item, Animation anim); -typedef Widget RemovedItemBuilder(BuildContext context, T item, Animation anim); +typedef Widget ItemBuilder( + BuildContext context, T item, Animation anim); +typedef Widget RemovedItemBuilder( + BuildContext context, T item, Animation anim); /// An [AnimatedList] that shows the result of a sally query stream. class SallyAnimatedList extends StatefulWidget { - final Stream> stream; final ItemBuilder itemBuilder; final RemovedItemBuilder removedItemBuilder; - SallyAnimatedList({@required this.stream, @required this.itemBuilder, @required this.removedItemBuilder}); + SallyAnimatedList( + {@required this.stream, + @required this.itemBuilder, + @required this.removedItemBuilder}); @override _SallyAnimatedListState createState() { @@ -22,7 +26,6 @@ class SallyAnimatedList extends StatefulWidget { } class _SallyAnimatedListState extends State> { - List _lastSnapshot; int _initialItemCount; @@ -101,8 +104,7 @@ class _SallyAnimatedListState extends State> { @override Widget build(BuildContext context) { - if (_lastSnapshot == null) - return const SizedBox(); + if (_lastSnapshot == null) return const SizedBox(); return AnimatedList( key: _key, @@ -115,4 +117,4 @@ class _SallyAnimatedListState extends State> { }, ); } -} \ No newline at end of file +} diff --git a/sally_flutter/lib/src/utils.dart b/sally_flutter/lib/src/utils.dart index f0022823..91355b40 100644 --- a/sally_flutter/lib/src/utils.dart +++ b/sally_flutter/lib/src/utils.dart @@ -1,3 +1 @@ -void insertIntoSortedList(List list, T entry, {int compare(T a, T b)}) { - -} \ No newline at end of file +void insertIntoSortedList(List list, T entry, {int compare(T a, T b)}) {}