mirror of https://github.com/AMT-Cheif/drift.git
Provide a sqflite / flutter based QueryExecutor
This commit is contained in:
parent
a2e3eb8a9d
commit
8a14b4e8d0
|
@ -28,6 +28,7 @@
|
||||||
<value>
|
<value>
|
||||||
<list>
|
<list>
|
||||||
<option value="$USER_HOME$/.pub-cache/hosted/pub.dartlang.org/async-2.0.8/lib" />
|
<option value="$USER_HOME$/.pub-cache/hosted/pub.dartlang.org/async-2.0.8/lib" />
|
||||||
|
<option value="$USER_HOME$/Android/flutter/.pub-cache/hosted/pub.dartlang.org/async-2.0.8/lib" />
|
||||||
</list>
|
</list>
|
||||||
</value>
|
</value>
|
||||||
</entry>
|
</entry>
|
||||||
|
@ -35,6 +36,7 @@
|
||||||
<value>
|
<value>
|
||||||
<list>
|
<list>
|
||||||
<option value="$USER_HOME$/.pub-cache/hosted/pub.dartlang.org/boolean_selector-1.0.4/lib" />
|
<option value="$USER_HOME$/.pub-cache/hosted/pub.dartlang.org/boolean_selector-1.0.4/lib" />
|
||||||
|
<option value="$USER_HOME$/Android/flutter/.pub-cache/hosted/pub.dartlang.org/boolean_selector-1.0.4/lib" />
|
||||||
</list>
|
</list>
|
||||||
</value>
|
</value>
|
||||||
</entry>
|
</entry>
|
||||||
|
@ -112,6 +114,7 @@
|
||||||
<value>
|
<value>
|
||||||
<list>
|
<list>
|
||||||
<option value="$USER_HOME$/.pub-cache/hosted/pub.dartlang.org/charcode-1.1.2/lib" />
|
<option value="$USER_HOME$/.pub-cache/hosted/pub.dartlang.org/charcode-1.1.2/lib" />
|
||||||
|
<option value="$USER_HOME$/Android/flutter/.pub-cache/hosted/pub.dartlang.org/charcode-1.1.2/lib" />
|
||||||
</list>
|
</list>
|
||||||
</value>
|
</value>
|
||||||
</entry>
|
</entry>
|
||||||
|
@ -126,6 +129,7 @@
|
||||||
<value>
|
<value>
|
||||||
<list>
|
<list>
|
||||||
<option value="$USER_HOME$/.pub-cache/hosted/pub.dartlang.org/collection-1.14.11/lib" />
|
<option value="$USER_HOME$/.pub-cache/hosted/pub.dartlang.org/collection-1.14.11/lib" />
|
||||||
|
<option value="$USER_HOME$/Android/flutter/.pub-cache/hosted/pub.dartlang.org/collection-1.14.11/lib" />
|
||||||
</list>
|
</list>
|
||||||
</value>
|
</value>
|
||||||
</entry>
|
</entry>
|
||||||
|
@ -164,6 +168,20 @@
|
||||||
</list>
|
</list>
|
||||||
</value>
|
</value>
|
||||||
</entry>
|
</entry>
|
||||||
|
<entry key="flutter">
|
||||||
|
<value>
|
||||||
|
<list>
|
||||||
|
<option value="$USER_HOME$/Android/flutter/packages/flutter/lib" />
|
||||||
|
</list>
|
||||||
|
</value>
|
||||||
|
</entry>
|
||||||
|
<entry key="flutter_test">
|
||||||
|
<value>
|
||||||
|
<list>
|
||||||
|
<option value="$USER_HOME$/Android/flutter/packages/flutter_test/lib" />
|
||||||
|
</list>
|
||||||
|
</value>
|
||||||
|
</entry>
|
||||||
<entry key="front_end">
|
<entry key="front_end">
|
||||||
<value>
|
<value>
|
||||||
<list>
|
<list>
|
||||||
|
@ -261,6 +279,7 @@
|
||||||
<value>
|
<value>
|
||||||
<list>
|
<list>
|
||||||
<option value="$USER_HOME$/.pub-cache/hosted/pub.dartlang.org/matcher-0.12.3+1/lib" />
|
<option value="$USER_HOME$/.pub-cache/hosted/pub.dartlang.org/matcher-0.12.3+1/lib" />
|
||||||
|
<option value="$USER_HOME$/Android/flutter/.pub-cache/hosted/pub.dartlang.org/matcher-0.12.3+1/lib" />
|
||||||
</list>
|
</list>
|
||||||
</value>
|
</value>
|
||||||
</entry>
|
</entry>
|
||||||
|
@ -268,6 +287,7 @@
|
||||||
<value>
|
<value>
|
||||||
<list>
|
<list>
|
||||||
<option value="$USER_HOME$/.pub-cache/hosted/pub.dartlang.org/meta-1.1.7/lib" />
|
<option value="$USER_HOME$/.pub-cache/hosted/pub.dartlang.org/meta-1.1.7/lib" />
|
||||||
|
<option value="$USER_HOME$/Android/flutter/.pub-cache/hosted/pub.dartlang.org/meta-1.1.6/lib" />
|
||||||
</list>
|
</list>
|
||||||
</value>
|
</value>
|
||||||
</entry>
|
</entry>
|
||||||
|
@ -317,6 +337,7 @@
|
||||||
<value>
|
<value>
|
||||||
<list>
|
<list>
|
||||||
<option value="$USER_HOME$/.pub-cache/hosted/pub.dartlang.org/path-1.6.2/lib" />
|
<option value="$USER_HOME$/.pub-cache/hosted/pub.dartlang.org/path-1.6.2/lib" />
|
||||||
|
<option value="$USER_HOME$/Android/flutter/.pub-cache/hosted/pub.dartlang.org/path-1.6.2/lib" />
|
||||||
</list>
|
</list>
|
||||||
</value>
|
</value>
|
||||||
</entry>
|
</entry>
|
||||||
|
@ -359,6 +380,7 @@
|
||||||
<value>
|
<value>
|
||||||
<list>
|
<list>
|
||||||
<option value="$USER_HOME$/.pub-cache/hosted/pub.dartlang.org/quiver-2.0.1/lib" />
|
<option value="$USER_HOME$/.pub-cache/hosted/pub.dartlang.org/quiver-2.0.1/lib" />
|
||||||
|
<option value="$USER_HOME$/Android/flutter/.pub-cache/hosted/pub.dartlang.org/quiver-2.0.1/lib" />
|
||||||
</list>
|
</list>
|
||||||
</value>
|
</value>
|
||||||
</entry>
|
</entry>
|
||||||
|
@ -397,6 +419,13 @@
|
||||||
</list>
|
</list>
|
||||||
</value>
|
</value>
|
||||||
</entry>
|
</entry>
|
||||||
|
<entry key="sky_engine">
|
||||||
|
<value>
|
||||||
|
<list>
|
||||||
|
<option value="$USER_HOME$/Android/flutter/bin/cache/pkg/sky_engine/lib" />
|
||||||
|
</list>
|
||||||
|
</value>
|
||||||
|
</entry>
|
||||||
<entry key="source_gen">
|
<entry key="source_gen">
|
||||||
<value>
|
<value>
|
||||||
<list>
|
<list>
|
||||||
|
@ -422,6 +451,14 @@
|
||||||
<value>
|
<value>
|
||||||
<list>
|
<list>
|
||||||
<option value="$USER_HOME$/.pub-cache/hosted/pub.dartlang.org/source_span-1.5.4/lib" />
|
<option value="$USER_HOME$/.pub-cache/hosted/pub.dartlang.org/source_span-1.5.4/lib" />
|
||||||
|
<option value="$USER_HOME$/Android/flutter/.pub-cache/hosted/pub.dartlang.org/source_span-1.4.1/lib" />
|
||||||
|
</list>
|
||||||
|
</value>
|
||||||
|
</entry>
|
||||||
|
<entry key="sqflite">
|
||||||
|
<value>
|
||||||
|
<list>
|
||||||
|
<option value="$USER_HOME$/Android/flutter/.pub-cache/hosted/pub.dartlang.org/sqflite-1.1.0/lib" />
|
||||||
</list>
|
</list>
|
||||||
</value>
|
</value>
|
||||||
</entry>
|
</entry>
|
||||||
|
@ -429,6 +466,7 @@
|
||||||
<value>
|
<value>
|
||||||
<list>
|
<list>
|
||||||
<option value="$USER_HOME$/.pub-cache/hosted/pub.dartlang.org/stack_trace-1.9.3/lib" />
|
<option value="$USER_HOME$/.pub-cache/hosted/pub.dartlang.org/stack_trace-1.9.3/lib" />
|
||||||
|
<option value="$USER_HOME$/Android/flutter/.pub-cache/hosted/pub.dartlang.org/stack_trace-1.9.3/lib" />
|
||||||
</list>
|
</list>
|
||||||
</value>
|
</value>
|
||||||
</entry>
|
</entry>
|
||||||
|
@ -436,6 +474,7 @@
|
||||||
<value>
|
<value>
|
||||||
<list>
|
<list>
|
||||||
<option value="$USER_HOME$/.pub-cache/hosted/pub.dartlang.org/stream_channel-1.6.8/lib" />
|
<option value="$USER_HOME$/.pub-cache/hosted/pub.dartlang.org/stream_channel-1.6.8/lib" />
|
||||||
|
<option value="$USER_HOME$/Android/flutter/.pub-cache/hosted/pub.dartlang.org/stream_channel-1.6.8/lib" />
|
||||||
</list>
|
</list>
|
||||||
</value>
|
</value>
|
||||||
</entry>
|
</entry>
|
||||||
|
@ -450,6 +489,14 @@
|
||||||
<value>
|
<value>
|
||||||
<list>
|
<list>
|
||||||
<option value="$USER_HOME$/.pub-cache/hosted/pub.dartlang.org/string_scanner-1.0.4/lib" />
|
<option value="$USER_HOME$/.pub-cache/hosted/pub.dartlang.org/string_scanner-1.0.4/lib" />
|
||||||
|
<option value="$USER_HOME$/Android/flutter/.pub-cache/hosted/pub.dartlang.org/string_scanner-1.0.4/lib" />
|
||||||
|
</list>
|
||||||
|
</value>
|
||||||
|
</entry>
|
||||||
|
<entry key="synchronized">
|
||||||
|
<value>
|
||||||
|
<list>
|
||||||
|
<option value="$USER_HOME$/Android/flutter/.pub-cache/hosted/pub.dartlang.org/synchronized-1.5.3+2/lib" />
|
||||||
</list>
|
</list>
|
||||||
</value>
|
</value>
|
||||||
</entry>
|
</entry>
|
||||||
|
@ -457,6 +504,7 @@
|
||||||
<value>
|
<value>
|
||||||
<list>
|
<list>
|
||||||
<option value="$USER_HOME$/.pub-cache/hosted/pub.dartlang.org/term_glyph-1.1.0/lib" />
|
<option value="$USER_HOME$/.pub-cache/hosted/pub.dartlang.org/term_glyph-1.1.0/lib" />
|
||||||
|
<option value="$USER_HOME$/Android/flutter/.pub-cache/hosted/pub.dartlang.org/term_glyph-1.0.1/lib" />
|
||||||
</list>
|
</list>
|
||||||
</value>
|
</value>
|
||||||
</entry>
|
</entry>
|
||||||
|
@ -471,6 +519,7 @@
|
||||||
<value>
|
<value>
|
||||||
<list>
|
<list>
|
||||||
<option value="$USER_HOME$/.pub-cache/hosted/pub.dartlang.org/test_api-0.2.2/lib" />
|
<option value="$USER_HOME$/.pub-cache/hosted/pub.dartlang.org/test_api-0.2.2/lib" />
|
||||||
|
<option value="$USER_HOME$/Android/flutter/.pub-cache/hosted/pub.dartlang.org/test_api-0.2.1/lib" />
|
||||||
</list>
|
</list>
|
||||||
</value>
|
</value>
|
||||||
</entry>
|
</entry>
|
||||||
|
@ -492,6 +541,7 @@
|
||||||
<value>
|
<value>
|
||||||
<list>
|
<list>
|
||||||
<option value="$USER_HOME$/.pub-cache/hosted/pub.dartlang.org/typed_data-1.1.6/lib" />
|
<option value="$USER_HOME$/.pub-cache/hosted/pub.dartlang.org/typed_data-1.1.6/lib" />
|
||||||
|
<option value="$USER_HOME$/Android/flutter/.pub-cache/hosted/pub.dartlang.org/typed_data-1.1.6/lib" />
|
||||||
</list>
|
</list>
|
||||||
</value>
|
</value>
|
||||||
</entry>
|
</entry>
|
||||||
|
@ -502,6 +552,13 @@
|
||||||
</list>
|
</list>
|
||||||
</value>
|
</value>
|
||||||
</entry>
|
</entry>
|
||||||
|
<entry key="vector_math">
|
||||||
|
<value>
|
||||||
|
<list>
|
||||||
|
<option value="$USER_HOME$/Android/flutter/.pub-cache/hosted/pub.dartlang.org/vector_math-2.0.8/lib" />
|
||||||
|
</list>
|
||||||
|
</value>
|
||||||
|
</entry>
|
||||||
<entry key="vm_service_client">
|
<entry key="vm_service_client">
|
||||||
<value>
|
<value>
|
||||||
<list>
|
<list>
|
||||||
|
@ -611,6 +668,27 @@
|
||||||
<root url="file://$USER_HOME$/.pub-cache/hosted/pub.dartlang.org/watcher-0.9.7+10/lib" />
|
<root url="file://$USER_HOME$/.pub-cache/hosted/pub.dartlang.org/watcher-0.9.7+10/lib" />
|
||||||
<root url="file://$USER_HOME$/.pub-cache/hosted/pub.dartlang.org/web_socket_channel-1.0.9/lib" />
|
<root url="file://$USER_HOME$/.pub-cache/hosted/pub.dartlang.org/web_socket_channel-1.0.9/lib" />
|
||||||
<root url="file://$USER_HOME$/.pub-cache/hosted/pub.dartlang.org/yaml-2.1.15/lib" />
|
<root url="file://$USER_HOME$/.pub-cache/hosted/pub.dartlang.org/yaml-2.1.15/lib" />
|
||||||
|
<root url="file://$USER_HOME$/Android/flutter/.pub-cache/hosted/pub.dartlang.org/async-2.0.8/lib" />
|
||||||
|
<root url="file://$USER_HOME$/Android/flutter/.pub-cache/hosted/pub.dartlang.org/boolean_selector-1.0.4/lib" />
|
||||||
|
<root url="file://$USER_HOME$/Android/flutter/.pub-cache/hosted/pub.dartlang.org/charcode-1.1.2/lib" />
|
||||||
|
<root url="file://$USER_HOME$/Android/flutter/.pub-cache/hosted/pub.dartlang.org/collection-1.14.11/lib" />
|
||||||
|
<root url="file://$USER_HOME$/Android/flutter/.pub-cache/hosted/pub.dartlang.org/matcher-0.12.3+1/lib" />
|
||||||
|
<root url="file://$USER_HOME$/Android/flutter/.pub-cache/hosted/pub.dartlang.org/meta-1.1.6/lib" />
|
||||||
|
<root url="file://$USER_HOME$/Android/flutter/.pub-cache/hosted/pub.dartlang.org/path-1.6.2/lib" />
|
||||||
|
<root url="file://$USER_HOME$/Android/flutter/.pub-cache/hosted/pub.dartlang.org/quiver-2.0.1/lib" />
|
||||||
|
<root url="file://$USER_HOME$/Android/flutter/.pub-cache/hosted/pub.dartlang.org/source_span-1.4.1/lib" />
|
||||||
|
<root url="file://$USER_HOME$/Android/flutter/.pub-cache/hosted/pub.dartlang.org/sqflite-1.1.0/lib" />
|
||||||
|
<root url="file://$USER_HOME$/Android/flutter/.pub-cache/hosted/pub.dartlang.org/stack_trace-1.9.3/lib" />
|
||||||
|
<root url="file://$USER_HOME$/Android/flutter/.pub-cache/hosted/pub.dartlang.org/stream_channel-1.6.8/lib" />
|
||||||
|
<root url="file://$USER_HOME$/Android/flutter/.pub-cache/hosted/pub.dartlang.org/string_scanner-1.0.4/lib" />
|
||||||
|
<root url="file://$USER_HOME$/Android/flutter/.pub-cache/hosted/pub.dartlang.org/synchronized-1.5.3+2/lib" />
|
||||||
|
<root url="file://$USER_HOME$/Android/flutter/.pub-cache/hosted/pub.dartlang.org/term_glyph-1.0.1/lib" />
|
||||||
|
<root url="file://$USER_HOME$/Android/flutter/.pub-cache/hosted/pub.dartlang.org/test_api-0.2.1/lib" />
|
||||||
|
<root url="file://$USER_HOME$/Android/flutter/.pub-cache/hosted/pub.dartlang.org/typed_data-1.1.6/lib" />
|
||||||
|
<root url="file://$USER_HOME$/Android/flutter/.pub-cache/hosted/pub.dartlang.org/vector_math-2.0.8/lib" />
|
||||||
|
<root url="file://$USER_HOME$/Android/flutter/bin/cache/pkg/sky_engine/lib" />
|
||||||
|
<root url="file://$USER_HOME$/Android/flutter/packages/flutter/lib" />
|
||||||
|
<root url="file://$USER_HOME$/Android/flutter/packages/flutter_test/lib" />
|
||||||
</CLASSES>
|
</CLASSES>
|
||||||
<JAVADOC />
|
<JAVADOC />
|
||||||
<SOURCES />
|
<SOURCES />
|
||||||
|
|
|
@ -4,6 +4,7 @@
|
||||||
<modules>
|
<modules>
|
||||||
<module fileurl="file://$PROJECT_DIR$/example/example.iml" filepath="$PROJECT_DIR$/example/example.iml" />
|
<module fileurl="file://$PROJECT_DIR$/example/example.iml" filepath="$PROJECT_DIR$/example/example.iml" />
|
||||||
<module fileurl="file://$PROJECT_DIR$/sally/sally.iml" filepath="$PROJECT_DIR$/sally/sally.iml" />
|
<module fileurl="file://$PROJECT_DIR$/sally/sally.iml" filepath="$PROJECT_DIR$/sally/sally.iml" />
|
||||||
|
<module fileurl="file://$PROJECT_DIR$/sally_flutter/sally_flutter.iml" filepath="$PROJECT_DIR$/sally_flutter/sally_flutter.iml" />
|
||||||
<module fileurl="file://$PROJECT_DIR$/sally_generator/sally_generator.iml" filepath="$PROJECT_DIR$/sally_generator/sally_generator.iml" />
|
<module fileurl="file://$PROJECT_DIR$/sally_generator/sally_generator.iml" filepath="$PROJECT_DIR$/sally_generator/sally_generator.iml" />
|
||||||
</modules>
|
</modules>
|
||||||
</component>
|
</component>
|
||||||
|
|
|
@ -16,6 +16,21 @@ abstract class GeneratedDatabase {
|
||||||
|
|
||||||
GeneratedDatabase(this.typeSystem, this.executor);
|
GeneratedDatabase(this.typeSystem, this.executor);
|
||||||
|
|
||||||
|
/// Creates a migrator with the provided query executor. We sometimes can't
|
||||||
|
/// use the regular [GeneratedDatabase.executor] because migration happens
|
||||||
|
/// before that executor is ready.
|
||||||
|
Migrator _createMigrator(QueryExecutor executor) => Migrator(this, executor);
|
||||||
|
|
||||||
|
Future<void> handleDatabaseCreation(QueryExecutor executor) {
|
||||||
|
final migrator = _createMigrator(executor);
|
||||||
|
return migration.onCreate(migrator);
|
||||||
|
}
|
||||||
|
|
||||||
|
Future<void> handleDatabaseVersionChange(QueryExecutor executor, int from, int to) {
|
||||||
|
final migrator = _createMigrator(executor);
|
||||||
|
return migration.onUpgrade(migrator, from, to);
|
||||||
|
}
|
||||||
|
|
||||||
SelectStatement<Table, ReturnType> select<Table, ReturnType>(
|
SelectStatement<Table, ReturnType> select<Table, ReturnType>(
|
||||||
TableInfo<Table, ReturnType> table) {
|
TableInfo<Table, ReturnType> table) {
|
||||||
return SelectStatement<Table, ReturnType>(this, table);
|
return SelectStatement<Table, ReturnType>(this, table);
|
||||||
|
@ -26,10 +41,13 @@ abstract class GeneratedDatabase {
|
||||||
}
|
}
|
||||||
|
|
||||||
abstract class QueryExecutor {
|
abstract class QueryExecutor {
|
||||||
|
|
||||||
|
GeneratedDatabase databaseInfo;
|
||||||
|
|
||||||
Future<bool> ensureOpen();
|
Future<bool> ensureOpen();
|
||||||
Future<List<Map<String, dynamic>>> runSelect(
|
Future<List<Map<String, dynamic>>> runSelect(
|
||||||
String statement, List<dynamic> args);
|
String statement, List<dynamic> args);
|
||||||
List<int> runInsert(String statement, List<dynamic> args);
|
Future<int> runInsert(String statement, List<dynamic> args);
|
||||||
Future<int> runUpdate(String statement, List<dynamic> args);
|
Future<int> runUpdate(String statement, List<dynamic> args);
|
||||||
Future<int> runDelete(String statement, List<dynamic> args);
|
Future<int> runDelete(String statement, List<dynamic> args);
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,3 +1,4 @@
|
||||||
|
import 'package:sally/sally.dart';
|
||||||
import 'package:sally/src/runtime/structure/columns.dart';
|
import 'package:sally/src/runtime/structure/columns.dart';
|
||||||
import 'package:sally/src/runtime/structure/table_info.dart';
|
import 'package:sally/src/runtime/structure/table_info.dart';
|
||||||
|
|
||||||
|
@ -21,6 +22,12 @@ class MigrationStrategy {
|
||||||
}
|
}
|
||||||
|
|
||||||
class Migrator {
|
class Migrator {
|
||||||
|
|
||||||
|
final GeneratedDatabase _db;
|
||||||
|
final QueryExecutor _customExecutor;
|
||||||
|
|
||||||
|
Migrator(this._db, this._customExecutor);
|
||||||
|
|
||||||
Future<void> createAllTables() async {}
|
Future<void> createAllTables() async {}
|
||||||
|
|
||||||
Future<void> createTable(TableInfo table) async {}
|
Future<void> createTable(TableInfo table) async {}
|
||||||
|
|
|
@ -5,7 +5,7 @@ description: A starting point for Dart libraries or applications.
|
||||||
# author: Simon Binder <email@example.com>
|
# author: Simon Binder <email@example.com>
|
||||||
|
|
||||||
environment:
|
environment:
|
||||||
sdk: '>=2.1.0 <3.0.0'
|
sdk: '>=2.0.0 <3.0.0'
|
||||||
|
|
||||||
dependencies:
|
dependencies:
|
||||||
meta: '>= 1.0.0 <2.0.0'
|
meta: '>= 1.0.0 <2.0.0'
|
||||||
|
|
|
@ -0,0 +1 @@
|
||||||
|
sqflite=/home/simon/Android/flutter/.pub-cache/hosted/pub.dartlang.org/sqflite-1.1.0/
|
|
@ -0,0 +1,10 @@
|
||||||
|
.DS_Store
|
||||||
|
.dart_tool/
|
||||||
|
|
||||||
|
.packages
|
||||||
|
.pub/
|
||||||
|
|
||||||
|
build/
|
||||||
|
ios/.generated/
|
||||||
|
ios/Flutter/Generated.xcconfig
|
||||||
|
ios/Runner/GeneratedPluginRegistrant.*
|
|
@ -0,0 +1,10 @@
|
||||||
|
# This file tracks properties of this Flutter project.
|
||||||
|
# Used by Flutter tool to assess capabilities and perform upgrades etc.
|
||||||
|
#
|
||||||
|
# This file should be version controlled and should not be manually edited.
|
||||||
|
|
||||||
|
version:
|
||||||
|
revision: 5391447fae6209bb21a89e6a5a6583cac1af9b4b
|
||||||
|
channel: stable
|
||||||
|
|
||||||
|
project_type: package
|
|
@ -0,0 +1,3 @@
|
||||||
|
## [0.0.1] - TODO: Add release date.
|
||||||
|
|
||||||
|
* TODO: Describe initial release.
|
|
@ -0,0 +1 @@
|
||||||
|
TODO: Add your license here.
|
|
@ -0,0 +1,14 @@
|
||||||
|
# sally_flutter
|
||||||
|
|
||||||
|
Flutter implementation for the sally database
|
||||||
|
|
||||||
|
## Getting Started
|
||||||
|
|
||||||
|
This project is a starting point for a Dart
|
||||||
|
[package](https://flutter.io/developing-packages/),
|
||||||
|
a library module containing code that can be shared easily across
|
||||||
|
multiple Flutter or Dart projects.
|
||||||
|
|
||||||
|
For help getting started with Flutter, view our
|
||||||
|
[online documentation](https://flutter.io/docs), which offers tutorials,
|
||||||
|
samples, guidance on mobile development, and a full API reference.
|
|
@ -0,0 +1,100 @@
|
||||||
|
/// Flutter implementation for the sally database. This library merely provides
|
||||||
|
/// a thin level of abstraction between the
|
||||||
|
/// [sqflite](https://pub.dartlang.org/packages/sqflite) library and
|
||||||
|
/// [sally](https://github.com/simolus3/sally)
|
||||||
|
library sally_flutter;
|
||||||
|
|
||||||
|
import 'package:meta/meta.dart';
|
||||||
|
import 'package:path/path.dart';
|
||||||
|
import 'package:sally/sally.dart';
|
||||||
|
import 'package:sqflite/sqflite.dart';
|
||||||
|
|
||||||
|
/// A query executor that uses sqlfite internally.
|
||||||
|
class FlutterQueryExecutor extends QueryExecutor {
|
||||||
|
final bool _inDbPath;
|
||||||
|
final String path;
|
||||||
|
Database _db;
|
||||||
|
|
||||||
|
FlutterQueryExecutor({@required this.path}) : _inDbPath = false;
|
||||||
|
|
||||||
|
FlutterQueryExecutor.inDatabaseFolder(this.path) : _inDbPath = true;
|
||||||
|
|
||||||
|
@override
|
||||||
|
Future<bool> ensureOpen() async {
|
||||||
|
if (_db != null && _db.isOpen) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
String resolvedPath;
|
||||||
|
if (_inDbPath) {
|
||||||
|
resolvedPath = join(await getDatabasesPath(), path);
|
||||||
|
} else {
|
||||||
|
resolvedPath = path;
|
||||||
|
}
|
||||||
|
|
||||||
|
_db = await openDatabase(
|
||||||
|
resolvedPath,
|
||||||
|
version: databaseInfo.schemaVersion,
|
||||||
|
onCreate: (db, version) {
|
||||||
|
return databaseInfo.handleDatabaseCreation(_SqfliteExecutor(db));
|
||||||
|
},
|
||||||
|
onUpgrade: (db, from, to) {
|
||||||
|
return databaseInfo.handleDatabaseVersionChange(
|
||||||
|
_SqfliteExecutor(db), from, to);
|
||||||
|
},
|
||||||
|
);
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
@override
|
||||||
|
Future<int> runDelete(String statement, List args) {
|
||||||
|
return _db.rawDelete(statement, args);
|
||||||
|
}
|
||||||
|
|
||||||
|
@override
|
||||||
|
Future<int> runInsert(String statement, List args) {
|
||||||
|
return _db.rawInsert(statement, args);
|
||||||
|
}
|
||||||
|
|
||||||
|
@override
|
||||||
|
Future<List<Map<String, dynamic>>> runSelect(String statement, List args) {
|
||||||
|
return _db.rawQuery(statement, args);
|
||||||
|
}
|
||||||
|
|
||||||
|
@override
|
||||||
|
Future<int> runUpdate(String statement, List args) {
|
||||||
|
return _db.rawUpdate(statement, args);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
class _SqfliteExecutor extends QueryExecutor {
|
||||||
|
final Database _db;
|
||||||
|
|
||||||
|
_SqfliteExecutor(this._db);
|
||||||
|
|
||||||
|
@override
|
||||||
|
Future<bool> ensureOpen() async {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
@override
|
||||||
|
Future<int> runDelete(String statement, List args) {
|
||||||
|
return _db.rawDelete(statement, args);
|
||||||
|
}
|
||||||
|
|
||||||
|
@override
|
||||||
|
Future<int> runInsert(String statement, List args) {
|
||||||
|
return _db.rawInsert(statement, args);
|
||||||
|
}
|
||||||
|
|
||||||
|
@override
|
||||||
|
Future<List<Map<String, dynamic>>> runSelect(String statement, List args) {
|
||||||
|
return _db.rawQuery(statement, args);
|
||||||
|
}
|
||||||
|
|
||||||
|
@override
|
||||||
|
Future<int> runUpdate(String statement, List args) {
|
||||||
|
return _db.rawUpdate(statement, args);
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,153 @@
|
||||||
|
# Generated by pub
|
||||||
|
# See https://www.dartlang.org/tools/pub/glossary#lockfile
|
||||||
|
packages:
|
||||||
|
async:
|
||||||
|
dependency: transitive
|
||||||
|
description:
|
||||||
|
name: async
|
||||||
|
url: "https://pub.dartlang.org"
|
||||||
|
source: hosted
|
||||||
|
version: "2.0.8"
|
||||||
|
boolean_selector:
|
||||||
|
dependency: transitive
|
||||||
|
description:
|
||||||
|
name: boolean_selector
|
||||||
|
url: "https://pub.dartlang.org"
|
||||||
|
source: hosted
|
||||||
|
version: "1.0.4"
|
||||||
|
charcode:
|
||||||
|
dependency: transitive
|
||||||
|
description:
|
||||||
|
name: charcode
|
||||||
|
url: "https://pub.dartlang.org"
|
||||||
|
source: hosted
|
||||||
|
version: "1.1.2"
|
||||||
|
collection:
|
||||||
|
dependency: transitive
|
||||||
|
description:
|
||||||
|
name: collection
|
||||||
|
url: "https://pub.dartlang.org"
|
||||||
|
source: hosted
|
||||||
|
version: "1.14.11"
|
||||||
|
flutter:
|
||||||
|
dependency: "direct main"
|
||||||
|
description: flutter
|
||||||
|
source: sdk
|
||||||
|
version: "0.0.0"
|
||||||
|
flutter_test:
|
||||||
|
dependency: "direct dev"
|
||||||
|
description: flutter
|
||||||
|
source: sdk
|
||||||
|
version: "0.0.0"
|
||||||
|
matcher:
|
||||||
|
dependency: transitive
|
||||||
|
description:
|
||||||
|
name: matcher
|
||||||
|
url: "https://pub.dartlang.org"
|
||||||
|
source: hosted
|
||||||
|
version: "0.12.3+1"
|
||||||
|
meta:
|
||||||
|
dependency: transitive
|
||||||
|
description:
|
||||||
|
name: meta
|
||||||
|
url: "https://pub.dartlang.org"
|
||||||
|
source: hosted
|
||||||
|
version: "1.1.6"
|
||||||
|
path:
|
||||||
|
dependency: "direct main"
|
||||||
|
description:
|
||||||
|
name: path
|
||||||
|
url: "https://pub.dartlang.org"
|
||||||
|
source: hosted
|
||||||
|
version: "1.6.2"
|
||||||
|
quiver:
|
||||||
|
dependency: transitive
|
||||||
|
description:
|
||||||
|
name: quiver
|
||||||
|
url: "https://pub.dartlang.org"
|
||||||
|
source: hosted
|
||||||
|
version: "2.0.1"
|
||||||
|
sally:
|
||||||
|
dependency: "direct main"
|
||||||
|
description:
|
||||||
|
path: "../sally"
|
||||||
|
relative: true
|
||||||
|
source: path
|
||||||
|
version: "0.0.0"
|
||||||
|
sky_engine:
|
||||||
|
dependency: transitive
|
||||||
|
description: flutter
|
||||||
|
source: sdk
|
||||||
|
version: "0.0.99"
|
||||||
|
source_span:
|
||||||
|
dependency: transitive
|
||||||
|
description:
|
||||||
|
name: source_span
|
||||||
|
url: "https://pub.dartlang.org"
|
||||||
|
source: hosted
|
||||||
|
version: "1.4.1"
|
||||||
|
sqflite:
|
||||||
|
dependency: "direct main"
|
||||||
|
description:
|
||||||
|
name: sqflite
|
||||||
|
url: "https://pub.dartlang.org"
|
||||||
|
source: hosted
|
||||||
|
version: "1.1.0"
|
||||||
|
stack_trace:
|
||||||
|
dependency: transitive
|
||||||
|
description:
|
||||||
|
name: stack_trace
|
||||||
|
url: "https://pub.dartlang.org"
|
||||||
|
source: hosted
|
||||||
|
version: "1.9.3"
|
||||||
|
stream_channel:
|
||||||
|
dependency: transitive
|
||||||
|
description:
|
||||||
|
name: stream_channel
|
||||||
|
url: "https://pub.dartlang.org"
|
||||||
|
source: hosted
|
||||||
|
version: "1.6.8"
|
||||||
|
string_scanner:
|
||||||
|
dependency: transitive
|
||||||
|
description:
|
||||||
|
name: string_scanner
|
||||||
|
url: "https://pub.dartlang.org"
|
||||||
|
source: hosted
|
||||||
|
version: "1.0.4"
|
||||||
|
synchronized:
|
||||||
|
dependency: transitive
|
||||||
|
description:
|
||||||
|
name: synchronized
|
||||||
|
url: "https://pub.dartlang.org"
|
||||||
|
source: hosted
|
||||||
|
version: "1.5.3+2"
|
||||||
|
term_glyph:
|
||||||
|
dependency: transitive
|
||||||
|
description:
|
||||||
|
name: term_glyph
|
||||||
|
url: "https://pub.dartlang.org"
|
||||||
|
source: hosted
|
||||||
|
version: "1.0.1"
|
||||||
|
test_api:
|
||||||
|
dependency: transitive
|
||||||
|
description:
|
||||||
|
name: test_api
|
||||||
|
url: "https://pub.dartlang.org"
|
||||||
|
source: hosted
|
||||||
|
version: "0.2.1"
|
||||||
|
typed_data:
|
||||||
|
dependency: transitive
|
||||||
|
description:
|
||||||
|
name: typed_data
|
||||||
|
url: "https://pub.dartlang.org"
|
||||||
|
source: hosted
|
||||||
|
version: "1.1.6"
|
||||||
|
vector_math:
|
||||||
|
dependency: transitive
|
||||||
|
description:
|
||||||
|
name: vector_math
|
||||||
|
url: "https://pub.dartlang.org"
|
||||||
|
source: hosted
|
||||||
|
version: "2.0.8"
|
||||||
|
sdks:
|
||||||
|
dart: ">=2.0.0 <3.0.0"
|
|
@ -0,0 +1,21 @@
|
||||||
|
name: sally_flutter
|
||||||
|
description: Flutter implementation for the sally database
|
||||||
|
version: 0.0.1
|
||||||
|
author:
|
||||||
|
homepage:
|
||||||
|
|
||||||
|
environment:
|
||||||
|
sdk: ">=2.0.0-dev.68.0 <3.0.0"
|
||||||
|
|
||||||
|
dependencies:
|
||||||
|
sally:
|
||||||
|
path: ../sally
|
||||||
|
sqflite: ^1.1.0
|
||||||
|
path: ^1.6.0
|
||||||
|
flutter:
|
||||||
|
sdk: flutter
|
||||||
|
|
||||||
|
dev_dependencies:
|
||||||
|
flutter_test:
|
||||||
|
sdk: flutter
|
||||||
|
|
Loading…
Reference in New Issue