diff --git a/.idea/modules.xml b/.idea/modules.xml index 1499236b..5dddd48c 100644 --- a/.idea/modules.xml +++ b/.idea/modules.xml @@ -2,7 +2,6 @@ - diff --git a/example/.flutter-plugins b/example/.flutter-plugins deleted file mode 100644 index 3e4cc2a8..00000000 --- a/example/.flutter-plugins +++ /dev/null @@ -1 +0,0 @@ -sqflite=/home/simon/Android/flutter/.pub-cache/hosted/pub.dartlang.org/sqflite-1.1.0/ diff --git a/example/.gitignore b/example/.gitignore deleted file mode 100644 index f95ca619..00000000 --- a/example/.gitignore +++ /dev/null @@ -1,107 +0,0 @@ - -# Created by https://www.gitignore.io/api/dart,intellij -# Edit at https://www.gitignore.io/?templates=dart,intellij - -### Dart ### -# See https://www.dartlang.org/guides/libraries/private-files - -# Files and directories created by pub -.dart_tool/ -.packages -build/ -# If you're building an application, you may want to check-in your pubspec.lock -pubspec.lock - -# Directory created by dartdoc -# If you don't generate documentation locally you can remove this line. -doc/api/ - -# Avoid committing generated Javascript files: -*.dart.js -*.info.json # Produced by the --dump-info flag. -*.js # When generated by dart2js. Don't specify *.js if your - # project includes source files written in JavaScript. -*.js_ -*.js.deps -*.js.map - -### Intellij ### -# Covers JetBrains IDEs: IntelliJ, RubyMine, PhpStorm, AppCode, PyCharm, CLion, Android Studio and WebStorm -# Reference: https://intellij-support.jetbrains.com/hc/en-us/articles/206544839 - -# User-specific stuff -.idea/**/workspace.xml -.idea/**/tasks.xml -.idea/**/usage.statistics.xml -.idea/**/dictionaries -.idea/**/shelf - -# Generated files -.idea/**/contentModel.xml - -# Sensitive or high-churn files -.idea/**/dataSources/ -.idea/**/dataSources.ids -.idea/**/dataSources.local.xml -.idea/**/sqlDataSources.xml -.idea/**/dynamic.xml -.idea/**/uiDesigner.xml -.idea/**/dbnavigator.xml - -# Gradle -.idea/**/gradle.xml -.idea/**/libraries - -# Gradle and Maven with auto-import -# When using Gradle or Maven with auto-import, you should exclude module files, -# since they will be recreated, and may cause churn. Uncomment if using -# auto-import. -# .idea/modules.xml -# .idea/*.iml -# .idea/modules - -# CMake -cmake-build-*/ - -# Mongo Explorer plugin -.idea/**/mongoSettings.xml - -# File-based project format -*.iws - -# IntelliJ -out/ - -# mpeltonen/sbt-idea plugin -.idea_modules/ - -# JIRA plugin -atlassian-ide-plugin.xml - -# Cursive Clojure plugin -.idea/replstate.xml - -# Crashlytics plugin (for Android Studio and IntelliJ) -com_crashlytics_export_strings.xml -crashlytics.properties -crashlytics-build.properties -fabric.properties - -# Editor-based Rest Client -.idea/httpRequests - -# Android studio 3.1+ serialized cache file -.idea/caches/build_file_checksums.ser - -### Intellij Patch ### -# Comment Reason: https://github.com/joeblau/gitignore.io/issues/186#issuecomment-215987721 - -# *.iml -# modules.xml -# .idea/misc.xml -# *.ipr - -# Sonarlint plugin -.idea/sonarlint - -# End of https://www.gitignore.io/api/dart,intellij diff --git a/example/CHANGELOG.md b/example/CHANGELOG.md deleted file mode 100644 index 687440ba..00000000 --- a/example/CHANGELOG.md +++ /dev/null @@ -1,3 +0,0 @@ -## 1.0.0 - -- Initial version, created by Stagehand diff --git a/example/LICENSE b/example/LICENSE deleted file mode 100644 index e4b21941..00000000 --- a/example/LICENSE +++ /dev/null @@ -1,21 +0,0 @@ -MIT License - -Copyright (c) 2019 Simon Binder - -Permission is hereby granted, free of charge, to any person obtaining a copy -of this software and associated documentation files (the "Software"), to deal -in the Software without restriction, including without limitation the rights -to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -copies of the Software, and to permit persons to whom the Software is -furnished to do so, subject to the following conditions: - -The above copyright notice and this permission notice shall be included in all -copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE -SOFTWARE. diff --git a/example/README.md b/example/README.md deleted file mode 100644 index af388e53..00000000 --- a/example/README.md +++ /dev/null @@ -1,4 +0,0 @@ -A sample command-line application. - -Created from templates made available by Stagehand under a BSD-style -[license](https://github.com/dart-lang/stagehand/blob/master/LICENSE). diff --git a/example/android/app/src/main/java/io/flutter/plugins/GeneratedPluginRegistrant.java b/example/android/app/src/main/java/io/flutter/plugins/GeneratedPluginRegistrant.java deleted file mode 100644 index aff2f141..00000000 --- a/example/android/app/src/main/java/io/flutter/plugins/GeneratedPluginRegistrant.java +++ /dev/null @@ -1,25 +0,0 @@ -package io.flutter.plugins; - -import io.flutter.plugin.common.PluginRegistry; -import com.tekartik.sqflite.SqflitePlugin; - -/** - * Generated file. Do not edit. - */ -public final class GeneratedPluginRegistrant { - public static void registerWith(PluginRegistry registry) { - if (alreadyRegisteredWith(registry)) { - return; - } - SqflitePlugin.registerWith(registry.registrarFor("com.tekartik.sqflite.SqflitePlugin")); - } - - private static boolean alreadyRegisteredWith(PluginRegistry registry) { - final String key = GeneratedPluginRegistrant.class.getCanonicalName(); - if (registry.hasPlugin(key)) { - return true; - } - registry.registrarFor(key); - return false; - } -} diff --git a/example/example.iml b/example/example.iml deleted file mode 100644 index 75734c90..00000000 --- a/example/example.iml +++ /dev/null @@ -1,14 +0,0 @@ - - - - - - - - - - - - - - \ No newline at end of file diff --git a/example/ios/Runner/GeneratedPluginRegistrant.h b/example/ios/Runner/GeneratedPluginRegistrant.h deleted file mode 100644 index 3b700eb4..00000000 --- a/example/ios/Runner/GeneratedPluginRegistrant.h +++ /dev/null @@ -1,14 +0,0 @@ -// -// Generated file. Do not edit. -// - -#ifndef GeneratedPluginRegistrant_h -#define GeneratedPluginRegistrant_h - -#import - -@interface GeneratedPluginRegistrant : NSObject -+ (void)registerWithRegistry:(NSObject*)registry; -@end - -#endif /* GeneratedPluginRegistrant_h */ diff --git a/example/ios/Runner/GeneratedPluginRegistrant.m b/example/ios/Runner/GeneratedPluginRegistrant.m deleted file mode 100644 index 8abd91ed..00000000 --- a/example/ios/Runner/GeneratedPluginRegistrant.m +++ /dev/null @@ -1,14 +0,0 @@ -// -// Generated file. Do not edit. -// - -#import "GeneratedPluginRegistrant.h" -#import - -@implementation GeneratedPluginRegistrant - -+ (void)registerWithRegistry:(NSObject*)registry { - [SqflitePlugin registerWithRegistrar:[registry registrarForPlugin:@"SqflitePlugin"]]; -} - -@end diff --git a/example/lib/example.dart b/example/lib/example.dart deleted file mode 100644 index 6a52aaab..00000000 --- a/example/lib/example.dart +++ /dev/null @@ -1,36 +0,0 @@ -import 'package:sally/sally.dart'; - -part 'example.g.dart'; - -class Products extends Table { - IntColumn get id => integer().named('products_id').autoIncrement()(); - TextColumn get name => text()(); -} - -class Users extends Table { - IntColumn get id => integer().autoIncrement()(); - TextColumn get name => text().withLength(min: 6, max: 32)(); -} - -@DataClassName('TodoEntry') -class Todos extends Table { - - IntColumn get id => integer().autoIncrement()(); - TextColumn get name => text().withLength(min: 6, max: 10)(); - TextColumn get content => text().named('body')(); -} - -@UseSally(tables: [Products, Users, Todos]) -class ShopDb extends _$ShopDb { - Future> allUsers() => select(users).get(); - Future> userByName(String name) => - (select(users)..where((u) => u.name.equals(name))).get(); - - Future deleteUser(User user) => - (delete(users)..where((u) => u.id.equals(user.id))).go(); - - @override - MigrationStrategy get migration => MigrationStrategy(); - @override - int get schemaVersion => 1; -} diff --git a/example/lib/example.g.dart b/example/lib/example.g.dart deleted file mode 100644 index 2479130d..00000000 --- a/example/lib/example.g.dart +++ /dev/null @@ -1,183 +0,0 @@ -// GENERATED CODE - DO NOT MODIFY BY HAND - -part of 'example.dart'; - -// ************************************************************************** -// SallyGenerator -// ************************************************************************** - -class Product { - final int id; - final String name; - Product({this.id, this.name}); - @override - int get hashCode => (id.hashCode) * 31 + name.hashCode; - @override - bool operator ==(other) => - identical(this, other) || - (other is Product && other.id == id && other.name == name); -} - -class _$ProductsTable extends Products implements TableInfo { - final GeneratedDatabase db; - _$ProductsTable(this.db); - @override - GeneratedIntColumn get id => GeneratedIntColumn('products_id', false); - @override - GeneratedTextColumn get name => GeneratedTextColumn('name', false); - @override - List get $columns => [id, name]; - @override - Products get asDslTable => this; - @override - String get $tableName => 'products'; - @override - void validateIntegrity(Product instance, bool isInserting) => null; - @override - Set get $primaryKey => Set(); - @override - Product map(Map data) { - final intType = db.typeSystem.forDartType(); - final stringType = db.typeSystem.forDartType(); - return Product( - id: intType.mapFromDatabaseResponse(data['products_id']), - name: stringType.mapFromDatabaseResponse(data['name']), - ); - } - - @override - Map entityToSql(Product d) { - final map = {}; - if (d.id != null) { - map['products_id'] = Variable(d.id); - } - if (d.name != null) { - map['name'] = Variable(d.name); - } - return map; - } -} - -class User { - final int id; - final String name; - User({this.id, this.name}); - @override - int get hashCode => (id.hashCode) * 31 + name.hashCode; - @override - bool operator ==(other) => - identical(this, other) || - (other is User && other.id == id && other.name == name); -} - -class _$UsersTable extends Users implements TableInfo { - final GeneratedDatabase db; - _$UsersTable(this.db); - @override - GeneratedIntColumn get id => GeneratedIntColumn('id', false); - @override - GeneratedTextColumn get name => GeneratedTextColumn('name', false); - @override - List get $columns => [id, name]; - @override - Users get asDslTable => this; - @override - String get $tableName => 'users'; - @override - void validateIntegrity(User instance, bool isInserting) => null; - @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']), - name: stringType.mapFromDatabaseResponse(data['name']), - ); - } - - @override - Map entityToSql(User d) { - final map = {}; - if (d.id != null) { - map['id'] = Variable(d.id); - } - if (d.name != null) { - map['name'] = Variable(d.name); - } - return map; - } -} - -class TodoEntry { - final int id; - final String name; - final String content; - TodoEntry({this.id, this.name, this.content}); - @override - int get hashCode => - ((id.hashCode) * 31 + name.hashCode) * 31 + content.hashCode; - @override - bool operator ==(other) => - identical(this, other) || - (other is TodoEntry && - other.id == id && - other.name == name && - other.content == content); -} - -class _$TodosTable extends Todos implements TableInfo { - final GeneratedDatabase db; - _$TodosTable(this.db); - @override - GeneratedIntColumn get id => GeneratedIntColumn('id', false); - @override - GeneratedTextColumn get name => GeneratedTextColumn('name', false); - @override - GeneratedTextColumn get content => GeneratedTextColumn('body', false); - @override - List get $columns => [id, name, content]; - @override - Todos get asDslTable => this; - @override - String get $tableName => 'todos'; - @override - void validateIntegrity(TodoEntry instance, bool isInserting) => null; - @override - Set get $primaryKey => Set(); - @override - TodoEntry map(Map data) { - final intType = db.typeSystem.forDartType(); - final stringType = db.typeSystem.forDartType(); - return TodoEntry( - id: intType.mapFromDatabaseResponse(data['id']), - name: stringType.mapFromDatabaseResponse(data['name']), - content: stringType.mapFromDatabaseResponse(data['body']), - ); - } - - @override - Map entityToSql(TodoEntry d) { - final map = {}; - if (d.id != null) { - map['id'] = Variable(d.id); - } - if (d.name != null) { - map['name'] = Variable(d.name); - } - if (d.content != null) { - map['body'] = Variable(d.content); - } - return map; - } -} - -abstract class _$ShopDb extends GeneratedDatabase { - _$ShopDb() : super(const SqlTypeSystem.withDefaults(), null); - _$ProductsTable get products => _$ProductsTable(this); - _$UsersTable get users => _$UsersTable(this); - _$TodosTable get todos => _$TodosTable(this); - @override - List get allTables => [products, users, todos]; -} diff --git a/example/pubspec.yaml b/example/pubspec.yaml deleted file mode 100644 index a650e14c..00000000 --- a/example/pubspec.yaml +++ /dev/null @@ -1,19 +0,0 @@ -name: example -description: A sample command-line application. -# version: 1.0.0 -# homepage: https://www.example.com -# author: simon - -environment: - sdk: '>=2.0.0 <3.0.0' - -dependencies: - sally: - path: ../sally - -dev_dependencies: - sally_generator: - path: ../sally_generator - build_runner: - pedantic: ^1.0.0 - test: ^1.0.0 diff --git a/sally_generator/lib/src/writer/database_writer.dart b/sally_generator/lib/src/writer/database_writer.dart index ce729e54..533d4ac0 100644 --- a/sally_generator/lib/src/writer/database_writer.dart +++ b/sally_generator/lib/src/writer/database_writer.dart @@ -16,7 +16,7 @@ class DatabaseWriter { // Write the database class final className = '_\$${db.fromClass.name}'; buffer.write('abstract class $className extends GeneratedDatabase {\n' - '$className() : super(const SqlTypeSystem.withDefaults(), null); \n'); + '$className(QueryExecutor e) : super(const SqlTypeSystem.withDefaults(), e); \n'); final tableGetters = [];