diff --git a/drift_sqflite/analysis_options.yaml b/drift_sqflite/analysis_options.yaml new file mode 100644 index 00000000..f9b30346 --- /dev/null +++ b/drift_sqflite/analysis_options.yaml @@ -0,0 +1 @@ +include: package:flutter_lints/flutter.yaml diff --git a/drift_sqflite/lib/drift_sqflite.dart b/drift_sqflite/lib/drift_sqflite.dart new file mode 100644 index 00000000..7587381d --- /dev/null +++ b/drift_sqflite/lib/drift_sqflite.dart @@ -0,0 +1,215 @@ +/// Flutter implementation for the drift database packages. +/// +/// The [SqfliteQueryExecutor] class can be used as a drift database +/// implementation based on the `sqflite` package. +library drift_sqflite; + +import 'dart:async'; +import 'dart:io'; + +import 'package:drift/backends.dart'; +import 'package:drift/drift.dart'; +import 'package:path/path.dart'; +import 'package:sqflite/sqflite.dart' as s; + +/// Signature of a function that runs when a database doesn't exist on file. +/// This can be useful to, for instance, load the database from an asset if it +/// doesn't exist. +typedef DatabaseCreator = FutureOr Function(File file); + +class _SqfliteDelegate extends DatabaseDelegate with _SqfliteExecutor { + @override + late s.Database db; + bool _isOpen = false; + + final bool inDbFolder; + final String path; + + bool singleInstance; + final DatabaseCreator? creator; + + _SqfliteDelegate(this.inDbFolder, this.path, + {this.singleInstance = true, this.creator}); + + @override + late final DbVersionDelegate versionDelegate = _SqfliteVersionDelegate(db); + + @override + TransactionDelegate get transactionDelegate => + _SqfliteTransactionDelegate(this); + + @override + bool get isOpen => _isOpen; + + @override + Future open(QueryExecutorUser user) async { + String resolvedPath; + if (inDbFolder) { + resolvedPath = join(await s.getDatabasesPath(), path); + } else { + resolvedPath = path; + } + + final file = File(resolvedPath); + if (creator != null && !await file.exists()) { + await creator!(file); + } + + // default value when no migration happened + db = await s.openDatabase( + resolvedPath, + singleInstance: singleInstance, + ); + _isOpen = true; + } + + @override + Future close() { + return db.close(); + } +} + +class _SqfliteVersionDelegate extends DynamicVersionDelegate { + final s.Database _db; + + _SqfliteVersionDelegate(this._db); + + @override + Future get schemaVersion async { + final result = await _db.rawQuery('PRAGMA user_version;'); + return result.single.values.first as int; + } + + @override + Future setSchemaVersion(int version) async { + await _db.rawUpdate('PRAGMA user_version = $version;'); + } +} + +class _SqfliteTransactionDelegate extends SupportedTransactionDelegate { + final _SqfliteDelegate delegate; + + _SqfliteTransactionDelegate(this.delegate); + + @override + void startTransaction(Future Function(QueryDelegate) run) { + delegate.db.transaction((transaction) async { + final executor = _SqfliteTransactionExecutor(transaction); + await run(executor); + }).catchError((_) { + // Ignore the error! We send a fake exception to indicate a rollback. + // sqflite will rollback, but the exception will bubble up. Here we stop + // the exception. + }); + } +} + +class _SqfliteTransactionExecutor extends QueryDelegate with _SqfliteExecutor { + @override + final s.DatabaseExecutor db; + + _SqfliteTransactionExecutor(this.db); +} + +mixin _SqfliteExecutor on QueryDelegate { + s.DatabaseExecutor get db; + + @override + Future runBatched(BatchedStatements statements) async { + final batch = db.batch(); + + for (final arg in statements.arguments) { + batch.execute(statements.statements[arg.statementIndex], arg.arguments); + } + + await batch.commit(noResult: true); + } + + @override + Future runCustom(String statement, List args) { + return db.execute(statement, args); + } + + @override + Future runInsert(String statement, List args) { + return db.rawInsert(statement, args); + } + + @override + Future runSelect(String statement, List args) async { + final result = await db.rawQuery(statement, args); + return QueryResult.fromRows(result); + } + + @override + Future runUpdate(String statement, List args) { + return db.rawUpdate(statement, args); + } +} + +/// A query executor that uses sqflite internally. +class SqfliteQueryExecutor extends DelegatedDatabase { + /// A query executor that will store the database in the file declared by + /// [path]. If [logStatements] is true, statements sent to the database will + /// be [print]ed, which can be handy for debugging. The [singleInstance] + /// parameter sets the corresponding parameter on [s.openDatabase]. + /// The [creator] will be called when the database file doesn't exist. It can + /// be used to, for instance, populate default data from an asset. Note that + /// migrations might behave differently when populating the database this way. + /// For instance, a database created by an [creator] will not receive the + /// [MigrationStrategy.onCreate] callback because it hasn't been created by + /// moor. + SqfliteQueryExecutor( + {required String path, + bool? logStatements, + bool singleInstance = true, + DatabaseCreator? creator}) + : super( + _SqfliteDelegate(false, path, + singleInstance: singleInstance, creator: creator), + logStatements: logStatements); + + /// A query executor that will store the database in the file declared by + /// [path], which will be resolved relative to [s.getDatabasesPath()]. + /// If [logStatements] is true, statements sent to the database will + /// be [print]ed, which can be handy for debugging. The [singleInstance] + /// parameter sets the corresponding parameter on [s.openDatabase]. + /// The [creator] will be called when the database file doesn't exist. It can + /// be used to, for instance, populate default data from an asset. Note that + /// migrations might behave differently when populating the database this way. + /// For instance, a database created by an [creator] will not receive the + /// [MigrationStrategy.onCreate] callback because it hasn't been created by + /// moor. + SqfliteQueryExecutor.inDatabaseFolder( + {required String path, + bool? logStatements, + bool singleInstance = true, + DatabaseCreator? creator}) + : super( + _SqfliteDelegate(true, path, + singleInstance: singleInstance, creator: creator), + logStatements: logStatements); + + /// The underlying sqflite [s.Database] object used by moor to send queries. + /// + /// Using the sqflite database can cause unexpected behavior in moor. For + /// instance, stream queries won't update for updates sent to the [s.Database] + /// directly. + /// For this reason, projects shouldn't use this getter unless they absolutely + /// need to. The database is exposed to make migrating from sqflite to moor + /// easier. + /// + /// Note that this returns null until the moor database has been opened. + /// A moor database is opened lazily when the first query runs. + s.Database? get sqfliteDb { + final sqfliteDelegate = delegate as _SqfliteDelegate; + return sqfliteDelegate.isOpen ? sqfliteDelegate.db : null; + } + + @override + // We're not really required to be sequential since sqflite has an internal + // lock to bring statements into a sequential order. + // Setting isSequential here helps with moor cancellations in stream queries + // though. + bool get isSequential => true; +} diff --git a/drift_sqflite/pubspec.yaml b/drift_sqflite/pubspec.yaml new file mode 100644 index 00000000..644e7fcc --- /dev/null +++ b/drift_sqflite/pubspec.yaml @@ -0,0 +1,21 @@ +name: drift_sqflite +description: A Flutter-only implementation of a drift database, based on the `sqflite` package. +version: 1.0.0 +repository: https://github.com/simolus3/drift +homepage: https://drift.simonbinder.eu/ +issue_tracker: https://github.com/simolus3/drift/issues + +environment: + sdk: '>=2.12.0 <3.0.0' + +dependencies: + drift: ^1.0.0 + sqflite: ^2.0.0+3 + path: ^1.8.0 + flutter: + sdk: flutter + +dev_dependencies: + flutter_lints: ^1.0.4 + flutter_test: + sdk: flutter diff --git a/extras/integration_tests/moor_flutter/.gitignore b/extras/integration_tests/sqflite/.gitignore similarity index 100% rename from extras/integration_tests/moor_flutter/.gitignore rename to extras/integration_tests/sqflite/.gitignore diff --git a/extras/integration_tests/moor_flutter/.metadata b/extras/integration_tests/sqflite/.metadata similarity index 100% rename from extras/integration_tests/moor_flutter/.metadata rename to extras/integration_tests/sqflite/.metadata diff --git a/extras/integration_tests/moor_flutter/README.md b/extras/integration_tests/sqflite/README.md similarity index 100% rename from extras/integration_tests/moor_flutter/README.md rename to extras/integration_tests/sqflite/README.md diff --git a/extras/integration_tests/moor_flutter/android/.gitignore b/extras/integration_tests/sqflite/android/.gitignore similarity index 91% rename from extras/integration_tests/moor_flutter/android/.gitignore rename to extras/integration_tests/sqflite/android/.gitignore index 0a741cb4..6f568019 100644 --- a/extras/integration_tests/moor_flutter/android/.gitignore +++ b/extras/integration_tests/sqflite/android/.gitignore @@ -9,3 +9,5 @@ GeneratedPluginRegistrant.java # Remember to never publicly share your keystore. # See https://flutter.dev/docs/deployment/android#reference-the-keystore-from-the-app key.properties +**/*.keystore +**/*.jks diff --git a/extras/integration_tests/moor_flutter/android/app/build.gradle b/extras/integration_tests/sqflite/android/app/build.gradle similarity index 81% rename from extras/integration_tests/moor_flutter/android/app/build.gradle rename to extras/integration_tests/sqflite/android/app/build.gradle index b68bcefc..8f70ca44 100644 --- a/extras/integration_tests/moor_flutter/android/app/build.gradle +++ b/extras/integration_tests/sqflite/android/app/build.gradle @@ -26,21 +26,26 @@ apply plugin: 'kotlin-android' apply from: "$flutterRoot/packages/flutter_tools/gradle/flutter.gradle" android { - compileSdkVersion 28 + compileSdkVersion flutter.compileSdkVersion + + compileOptions { + sourceCompatibility JavaVersion.VERSION_1_8 + targetCompatibility JavaVersion.VERSION_1_8 + } + + kotlinOptions { + jvmTarget = '1.8' + } sourceSets { main.java.srcDirs += 'src/main/kotlin' } - lintOptions { - disable 'InvalidPackage' - } - defaultConfig { // TODO: Specify your own unique Application ID (https://developer.android.com/studio/build/application-id.html). - applicationId "com.example.moor_flutter" - minSdkVersion 16 - targetSdkVersion 28 + applicationId "com.example.sqflite" + minSdkVersion flutter.minSdkVersion + targetSdkVersion flutter.targetSdkVersion versionCode flutterVersionCode.toInteger() versionName flutterVersionName } diff --git a/extras/integration_tests/moor_flutter/android/app/src/profile/AndroidManifest.xml b/extras/integration_tests/sqflite/android/app/src/debug/AndroidManifest.xml similarity index 87% rename from extras/integration_tests/moor_flutter/android/app/src/profile/AndroidManifest.xml rename to extras/integration_tests/sqflite/android/app/src/debug/AndroidManifest.xml index a9447e05..4059c692 100644 --- a/extras/integration_tests/moor_flutter/android/app/src/profile/AndroidManifest.xml +++ b/extras/integration_tests/sqflite/android/app/src/debug/AndroidManifest.xml @@ -1,5 +1,5 @@ + package="com.example.sqflite"> diff --git a/extras/integration_tests/moor_flutter/android/app/src/main/AndroidManifest.xml b/extras/integration_tests/sqflite/android/app/src/main/AndroidManifest.xml similarity index 58% rename from extras/integration_tests/moor_flutter/android/app/src/main/AndroidManifest.xml rename to extras/integration_tests/sqflite/android/app/src/main/AndroidManifest.xml index b9a34d56..2936bca2 100644 --- a/extras/integration_tests/moor_flutter/android/app/src/main/AndroidManifest.xml +++ b/extras/integration_tests/sqflite/android/app/src/main/AndroidManifest.xml @@ -1,16 +1,12 @@ - - + - - diff --git a/extras/integration_tests/moor_flutter/android/app/src/main/kotlin/com/example/moor_flutter/MainActivity.kt b/extras/integration_tests/sqflite/android/app/src/main/kotlin/com/example/sqflite/MainActivity.kt similarity index 74% rename from extras/integration_tests/moor_flutter/android/app/src/main/kotlin/com/example/moor_flutter/MainActivity.kt rename to extras/integration_tests/sqflite/android/app/src/main/kotlin/com/example/sqflite/MainActivity.kt index 8b6e32d7..683b881e 100644 --- a/extras/integration_tests/moor_flutter/android/app/src/main/kotlin/com/example/moor_flutter/MainActivity.kt +++ b/extras/integration_tests/sqflite/android/app/src/main/kotlin/com/example/sqflite/MainActivity.kt @@ -1,4 +1,4 @@ -package com.example.moor_flutter +package com.example.sqflite import io.flutter.embedding.android.FlutterActivity diff --git a/extras/integration_tests/sqflite/android/app/src/main/res/drawable-v21/launch_background.xml b/extras/integration_tests/sqflite/android/app/src/main/res/drawable-v21/launch_background.xml new file mode 100644 index 00000000..f74085f3 --- /dev/null +++ b/extras/integration_tests/sqflite/android/app/src/main/res/drawable-v21/launch_background.xml @@ -0,0 +1,12 @@ + + + + + + + + diff --git a/extras/integration_tests/moor_flutter/android/app/src/main/res/drawable/launch_background.xml b/extras/integration_tests/sqflite/android/app/src/main/res/drawable/launch_background.xml similarity index 100% rename from extras/integration_tests/moor_flutter/android/app/src/main/res/drawable/launch_background.xml rename to extras/integration_tests/sqflite/android/app/src/main/res/drawable/launch_background.xml diff --git a/extras/integration_tests/moor_flutter/android/app/src/main/res/mipmap-hdpi/ic_launcher.png b/extras/integration_tests/sqflite/android/app/src/main/res/mipmap-hdpi/ic_launcher.png similarity index 100% rename from extras/integration_tests/moor_flutter/android/app/src/main/res/mipmap-hdpi/ic_launcher.png rename to extras/integration_tests/sqflite/android/app/src/main/res/mipmap-hdpi/ic_launcher.png diff --git a/extras/integration_tests/moor_flutter/android/app/src/main/res/mipmap-mdpi/ic_launcher.png b/extras/integration_tests/sqflite/android/app/src/main/res/mipmap-mdpi/ic_launcher.png similarity index 100% rename from extras/integration_tests/moor_flutter/android/app/src/main/res/mipmap-mdpi/ic_launcher.png rename to extras/integration_tests/sqflite/android/app/src/main/res/mipmap-mdpi/ic_launcher.png diff --git a/extras/integration_tests/moor_flutter/android/app/src/main/res/mipmap-xhdpi/ic_launcher.png b/extras/integration_tests/sqflite/android/app/src/main/res/mipmap-xhdpi/ic_launcher.png similarity index 100% rename from extras/integration_tests/moor_flutter/android/app/src/main/res/mipmap-xhdpi/ic_launcher.png rename to extras/integration_tests/sqflite/android/app/src/main/res/mipmap-xhdpi/ic_launcher.png diff --git a/extras/integration_tests/moor_flutter/android/app/src/main/res/mipmap-xxhdpi/ic_launcher.png b/extras/integration_tests/sqflite/android/app/src/main/res/mipmap-xxhdpi/ic_launcher.png similarity index 100% rename from extras/integration_tests/moor_flutter/android/app/src/main/res/mipmap-xxhdpi/ic_launcher.png rename to extras/integration_tests/sqflite/android/app/src/main/res/mipmap-xxhdpi/ic_launcher.png diff --git a/extras/integration_tests/moor_flutter/android/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png b/extras/integration_tests/sqflite/android/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png similarity index 100% rename from extras/integration_tests/moor_flutter/android/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png rename to extras/integration_tests/sqflite/android/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png diff --git a/extras/integration_tests/moor_flutter/android/app/src/main/res/values/styles.xml b/extras/integration_tests/sqflite/android/app/src/main/res/values-night/styles.xml similarity index 86% rename from extras/integration_tests/moor_flutter/android/app/src/main/res/values/styles.xml rename to extras/integration_tests/sqflite/android/app/src/main/res/values-night/styles.xml index 1f83a33f..3db14bb5 100644 --- a/extras/integration_tests/moor_flutter/android/app/src/main/res/values/styles.xml +++ b/extras/integration_tests/sqflite/android/app/src/main/res/values-night/styles.xml @@ -1,6 +1,6 @@ - + diff --git a/extras/integration_tests/sqflite/android/app/src/main/res/values/styles.xml b/extras/integration_tests/sqflite/android/app/src/main/res/values/styles.xml new file mode 100644 index 00000000..d460d1e9 --- /dev/null +++ b/extras/integration_tests/sqflite/android/app/src/main/res/values/styles.xml @@ -0,0 +1,18 @@ + + + + + + + diff --git a/extras/integration_tests/moor_flutter/android/app/src/debug/AndroidManifest.xml b/extras/integration_tests/sqflite/android/app/src/profile/AndroidManifest.xml similarity index 87% rename from extras/integration_tests/moor_flutter/android/app/src/debug/AndroidManifest.xml rename to extras/integration_tests/sqflite/android/app/src/profile/AndroidManifest.xml index a9447e05..4059c692 100644 --- a/extras/integration_tests/moor_flutter/android/app/src/debug/AndroidManifest.xml +++ b/extras/integration_tests/sqflite/android/app/src/profile/AndroidManifest.xml @@ -1,5 +1,5 @@ + package="com.example.sqflite"> diff --git a/extras/integration_tests/moor_flutter/android/build.gradle b/extras/integration_tests/sqflite/android/build.gradle similarity index 76% rename from extras/integration_tests/moor_flutter/android/build.gradle rename to extras/integration_tests/sqflite/android/build.gradle index 3100ad2d..4256f917 100644 --- a/extras/integration_tests/moor_flutter/android/build.gradle +++ b/extras/integration_tests/sqflite/android/build.gradle @@ -1,12 +1,12 @@ buildscript { - ext.kotlin_version = '1.3.50' + ext.kotlin_version = '1.6.10' repositories { google() - jcenter() + mavenCentral() } dependencies { - classpath 'com.android.tools.build:gradle:3.5.0' + classpath 'com.android.tools.build:gradle:4.1.0' classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version" } } @@ -14,7 +14,7 @@ buildscript { allprojects { repositories { google() - jcenter() + mavenCentral() } } diff --git a/extras/integration_tests/moor_flutter/android/gradle.properties b/extras/integration_tests/sqflite/android/gradle.properties similarity index 78% rename from extras/integration_tests/moor_flutter/android/gradle.properties rename to extras/integration_tests/sqflite/android/gradle.properties index 38c8d454..94adc3a3 100644 --- a/extras/integration_tests/moor_flutter/android/gradle.properties +++ b/extras/integration_tests/sqflite/android/gradle.properties @@ -1,4 +1,3 @@ org.gradle.jvmargs=-Xmx1536M -android.enableR8=true android.useAndroidX=true android.enableJetifier=true diff --git a/extras/integration_tests/moor_flutter/android/gradle/wrapper/gradle-wrapper.properties b/extras/integration_tests/sqflite/android/gradle/wrapper/gradle-wrapper.properties similarity index 93% rename from extras/integration_tests/moor_flutter/android/gradle/wrapper/gradle-wrapper.properties rename to extras/integration_tests/sqflite/android/gradle/wrapper/gradle-wrapper.properties index 296b146b..bc6a58af 100644 --- a/extras/integration_tests/moor_flutter/android/gradle/wrapper/gradle-wrapper.properties +++ b/extras/integration_tests/sqflite/android/gradle/wrapper/gradle-wrapper.properties @@ -3,4 +3,4 @@ distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-5.6.2-all.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-6.7-all.zip diff --git a/extras/integration_tests/moor_flutter/android/settings.gradle b/extras/integration_tests/sqflite/android/settings.gradle similarity index 73% rename from extras/integration_tests/moor_flutter/android/settings.gradle rename to extras/integration_tests/sqflite/android/settings.gradle index d3b6a401..44e62bcf 100644 --- a/extras/integration_tests/moor_flutter/android/settings.gradle +++ b/extras/integration_tests/sqflite/android/settings.gradle @@ -1,7 +1,3 @@ -// Copyright 2014 The Flutter Authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - include ':app' def localPropertiesFile = new File(rootProject.projectDir, "local.properties") diff --git a/extras/integration_tests/moor_flutter/ios/.gitignore b/extras/integration_tests/sqflite/ios/.gitignore similarity index 100% rename from extras/integration_tests/moor_flutter/ios/.gitignore rename to extras/integration_tests/sqflite/ios/.gitignore diff --git a/extras/integration_tests/moor_flutter/ios/Flutter/AppFrameworkInfo.plist b/extras/integration_tests/sqflite/ios/Flutter/AppFrameworkInfo.plist similarity index 100% rename from extras/integration_tests/moor_flutter/ios/Flutter/AppFrameworkInfo.plist rename to extras/integration_tests/sqflite/ios/Flutter/AppFrameworkInfo.plist diff --git a/extras/integration_tests/moor_flutter/ios/Flutter/Debug.xcconfig b/extras/integration_tests/sqflite/ios/Flutter/Debug.xcconfig similarity index 100% rename from extras/integration_tests/moor_flutter/ios/Flutter/Debug.xcconfig rename to extras/integration_tests/sqflite/ios/Flutter/Debug.xcconfig diff --git a/extras/integration_tests/moor_flutter/ios/Flutter/Release.xcconfig b/extras/integration_tests/sqflite/ios/Flutter/Release.xcconfig similarity index 100% rename from extras/integration_tests/moor_flutter/ios/Flutter/Release.xcconfig rename to extras/integration_tests/sqflite/ios/Flutter/Release.xcconfig diff --git a/extras/integration_tests/moor_flutter/ios/Podfile b/extras/integration_tests/sqflite/ios/Podfile similarity index 100% rename from extras/integration_tests/moor_flutter/ios/Podfile rename to extras/integration_tests/sqflite/ios/Podfile diff --git a/extras/integration_tests/moor_flutter/ios/Runner.xcodeproj/project.pbxproj b/extras/integration_tests/sqflite/ios/Runner.xcodeproj/project.pbxproj similarity index 100% rename from extras/integration_tests/moor_flutter/ios/Runner.xcodeproj/project.pbxproj rename to extras/integration_tests/sqflite/ios/Runner.xcodeproj/project.pbxproj diff --git a/extras/integration_tests/moor_flutter/ios/Runner.xcodeproj/project.xcworkspace/contents.xcworkspacedata b/extras/integration_tests/sqflite/ios/Runner.xcodeproj/project.xcworkspace/contents.xcworkspacedata similarity index 100% rename from extras/integration_tests/moor_flutter/ios/Runner.xcodeproj/project.xcworkspace/contents.xcworkspacedata rename to extras/integration_tests/sqflite/ios/Runner.xcodeproj/project.xcworkspace/contents.xcworkspacedata diff --git a/extras/integration_tests/moor_flutter/ios/Runner.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist b/extras/integration_tests/sqflite/ios/Runner.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist similarity index 100% rename from extras/integration_tests/moor_flutter/ios/Runner.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist rename to extras/integration_tests/sqflite/ios/Runner.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist diff --git a/extras/integration_tests/moor_flutter/ios/Runner.xcodeproj/project.xcworkspace/xcshareddata/WorkspaceSettings.xcsettings b/extras/integration_tests/sqflite/ios/Runner.xcodeproj/project.xcworkspace/xcshareddata/WorkspaceSettings.xcsettings similarity index 100% rename from extras/integration_tests/moor_flutter/ios/Runner.xcodeproj/project.xcworkspace/xcshareddata/WorkspaceSettings.xcsettings rename to extras/integration_tests/sqflite/ios/Runner.xcodeproj/project.xcworkspace/xcshareddata/WorkspaceSettings.xcsettings diff --git a/extras/integration_tests/moor_flutter/ios/Runner.xcodeproj/xcshareddata/xcschemes/Runner.xcscheme b/extras/integration_tests/sqflite/ios/Runner.xcodeproj/xcshareddata/xcschemes/Runner.xcscheme similarity index 100% rename from extras/integration_tests/moor_flutter/ios/Runner.xcodeproj/xcshareddata/xcschemes/Runner.xcscheme rename to extras/integration_tests/sqflite/ios/Runner.xcodeproj/xcshareddata/xcschemes/Runner.xcscheme diff --git a/extras/integration_tests/moor_flutter/ios/Runner.xcworkspace/contents.xcworkspacedata b/extras/integration_tests/sqflite/ios/Runner.xcworkspace/contents.xcworkspacedata similarity index 100% rename from extras/integration_tests/moor_flutter/ios/Runner.xcworkspace/contents.xcworkspacedata rename to extras/integration_tests/sqflite/ios/Runner.xcworkspace/contents.xcworkspacedata diff --git a/extras/integration_tests/moor_flutter/ios/Runner.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist b/extras/integration_tests/sqflite/ios/Runner.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist similarity index 100% rename from extras/integration_tests/moor_flutter/ios/Runner.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist rename to extras/integration_tests/sqflite/ios/Runner.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist diff --git a/extras/integration_tests/moor_flutter/ios/Runner.xcworkspace/xcshareddata/WorkspaceSettings.xcsettings b/extras/integration_tests/sqflite/ios/Runner.xcworkspace/xcshareddata/WorkspaceSettings.xcsettings similarity index 100% rename from extras/integration_tests/moor_flutter/ios/Runner.xcworkspace/xcshareddata/WorkspaceSettings.xcsettings rename to extras/integration_tests/sqflite/ios/Runner.xcworkspace/xcshareddata/WorkspaceSettings.xcsettings diff --git a/extras/integration_tests/moor_flutter/ios/Runner/AppDelegate.swift b/extras/integration_tests/sqflite/ios/Runner/AppDelegate.swift similarity index 100% rename from extras/integration_tests/moor_flutter/ios/Runner/AppDelegate.swift rename to extras/integration_tests/sqflite/ios/Runner/AppDelegate.swift diff --git a/extras/integration_tests/moor_flutter/ios/Runner/Assets.xcassets/AppIcon.appiconset/Contents.json b/extras/integration_tests/sqflite/ios/Runner/Assets.xcassets/AppIcon.appiconset/Contents.json similarity index 100% rename from extras/integration_tests/moor_flutter/ios/Runner/Assets.xcassets/AppIcon.appiconset/Contents.json rename to extras/integration_tests/sqflite/ios/Runner/Assets.xcassets/AppIcon.appiconset/Contents.json diff --git a/extras/integration_tests/moor_flutter/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-1024x1024@1x.png b/extras/integration_tests/sqflite/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-1024x1024@1x.png similarity index 100% rename from extras/integration_tests/moor_flutter/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-1024x1024@1x.png rename to extras/integration_tests/sqflite/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-1024x1024@1x.png diff --git a/extras/integration_tests/moor_flutter/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-20x20@1x.png b/extras/integration_tests/sqflite/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-20x20@1x.png similarity index 100% rename from extras/integration_tests/moor_flutter/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-20x20@1x.png rename to extras/integration_tests/sqflite/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-20x20@1x.png diff --git a/extras/integration_tests/moor_flutter/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-20x20@2x.png b/extras/integration_tests/sqflite/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-20x20@2x.png similarity index 100% rename from extras/integration_tests/moor_flutter/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-20x20@2x.png rename to extras/integration_tests/sqflite/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-20x20@2x.png diff --git a/extras/integration_tests/moor_flutter/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-20x20@3x.png b/extras/integration_tests/sqflite/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-20x20@3x.png similarity index 100% rename from extras/integration_tests/moor_flutter/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-20x20@3x.png rename to extras/integration_tests/sqflite/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-20x20@3x.png diff --git a/extras/integration_tests/moor_flutter/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-29x29@1x.png b/extras/integration_tests/sqflite/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-29x29@1x.png similarity index 100% rename from extras/integration_tests/moor_flutter/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-29x29@1x.png rename to extras/integration_tests/sqflite/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-29x29@1x.png diff --git a/extras/integration_tests/moor_flutter/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-29x29@2x.png b/extras/integration_tests/sqflite/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-29x29@2x.png similarity index 100% rename from extras/integration_tests/moor_flutter/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-29x29@2x.png rename to extras/integration_tests/sqflite/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-29x29@2x.png diff --git a/extras/integration_tests/moor_flutter/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-29x29@3x.png b/extras/integration_tests/sqflite/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-29x29@3x.png similarity index 100% rename from extras/integration_tests/moor_flutter/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-29x29@3x.png rename to extras/integration_tests/sqflite/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-29x29@3x.png diff --git a/extras/integration_tests/moor_flutter/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-40x40@1x.png b/extras/integration_tests/sqflite/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-40x40@1x.png similarity index 100% rename from extras/integration_tests/moor_flutter/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-40x40@1x.png rename to extras/integration_tests/sqflite/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-40x40@1x.png diff --git a/extras/integration_tests/moor_flutter/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-40x40@2x.png b/extras/integration_tests/sqflite/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-40x40@2x.png similarity index 100% rename from extras/integration_tests/moor_flutter/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-40x40@2x.png rename to extras/integration_tests/sqflite/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-40x40@2x.png diff --git a/extras/integration_tests/moor_flutter/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-40x40@3x.png b/extras/integration_tests/sqflite/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-40x40@3x.png similarity index 100% rename from extras/integration_tests/moor_flutter/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-40x40@3x.png rename to extras/integration_tests/sqflite/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-40x40@3x.png diff --git a/extras/integration_tests/moor_flutter/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-60x60@2x.png b/extras/integration_tests/sqflite/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-60x60@2x.png similarity index 100% rename from extras/integration_tests/moor_flutter/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-60x60@2x.png rename to extras/integration_tests/sqflite/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-60x60@2x.png diff --git a/extras/integration_tests/moor_flutter/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-60x60@3x.png b/extras/integration_tests/sqflite/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-60x60@3x.png similarity index 100% rename from extras/integration_tests/moor_flutter/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-60x60@3x.png rename to extras/integration_tests/sqflite/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-60x60@3x.png diff --git a/extras/integration_tests/moor_flutter/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-76x76@1x.png b/extras/integration_tests/sqflite/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-76x76@1x.png similarity index 100% rename from extras/integration_tests/moor_flutter/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-76x76@1x.png rename to extras/integration_tests/sqflite/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-76x76@1x.png diff --git a/extras/integration_tests/moor_flutter/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-76x76@2x.png b/extras/integration_tests/sqflite/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-76x76@2x.png similarity index 100% rename from extras/integration_tests/moor_flutter/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-76x76@2x.png rename to extras/integration_tests/sqflite/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-76x76@2x.png diff --git a/extras/integration_tests/moor_flutter/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-83.5x83.5@2x.png b/extras/integration_tests/sqflite/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-83.5x83.5@2x.png similarity index 100% rename from extras/integration_tests/moor_flutter/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-83.5x83.5@2x.png rename to extras/integration_tests/sqflite/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-83.5x83.5@2x.png diff --git a/extras/integration_tests/moor_flutter/ios/Runner/Assets.xcassets/LaunchImage.imageset/Contents.json b/extras/integration_tests/sqflite/ios/Runner/Assets.xcassets/LaunchImage.imageset/Contents.json similarity index 100% rename from extras/integration_tests/moor_flutter/ios/Runner/Assets.xcassets/LaunchImage.imageset/Contents.json rename to extras/integration_tests/sqflite/ios/Runner/Assets.xcassets/LaunchImage.imageset/Contents.json diff --git a/extras/integration_tests/moor_flutter/ios/Runner/Assets.xcassets/LaunchImage.imageset/LaunchImage.png b/extras/integration_tests/sqflite/ios/Runner/Assets.xcassets/LaunchImage.imageset/LaunchImage.png similarity index 100% rename from extras/integration_tests/moor_flutter/ios/Runner/Assets.xcassets/LaunchImage.imageset/LaunchImage.png rename to extras/integration_tests/sqflite/ios/Runner/Assets.xcassets/LaunchImage.imageset/LaunchImage.png diff --git a/extras/integration_tests/moor_flutter/ios/Runner/Assets.xcassets/LaunchImage.imageset/LaunchImage@2x.png b/extras/integration_tests/sqflite/ios/Runner/Assets.xcassets/LaunchImage.imageset/LaunchImage@2x.png similarity index 100% rename from extras/integration_tests/moor_flutter/ios/Runner/Assets.xcassets/LaunchImage.imageset/LaunchImage@2x.png rename to extras/integration_tests/sqflite/ios/Runner/Assets.xcassets/LaunchImage.imageset/LaunchImage@2x.png diff --git a/extras/integration_tests/moor_flutter/ios/Runner/Assets.xcassets/LaunchImage.imageset/LaunchImage@3x.png b/extras/integration_tests/sqflite/ios/Runner/Assets.xcassets/LaunchImage.imageset/LaunchImage@3x.png similarity index 100% rename from extras/integration_tests/moor_flutter/ios/Runner/Assets.xcassets/LaunchImage.imageset/LaunchImage@3x.png rename to extras/integration_tests/sqflite/ios/Runner/Assets.xcassets/LaunchImage.imageset/LaunchImage@3x.png diff --git a/extras/integration_tests/moor_flutter/ios/Runner/Assets.xcassets/LaunchImage.imageset/README.md b/extras/integration_tests/sqflite/ios/Runner/Assets.xcassets/LaunchImage.imageset/README.md similarity index 100% rename from extras/integration_tests/moor_flutter/ios/Runner/Assets.xcassets/LaunchImage.imageset/README.md rename to extras/integration_tests/sqflite/ios/Runner/Assets.xcassets/LaunchImage.imageset/README.md diff --git a/extras/integration_tests/moor_flutter/ios/Runner/Base.lproj/LaunchScreen.storyboard b/extras/integration_tests/sqflite/ios/Runner/Base.lproj/LaunchScreen.storyboard similarity index 100% rename from extras/integration_tests/moor_flutter/ios/Runner/Base.lproj/LaunchScreen.storyboard rename to extras/integration_tests/sqflite/ios/Runner/Base.lproj/LaunchScreen.storyboard diff --git a/extras/integration_tests/moor_flutter/ios/Runner/Base.lproj/Main.storyboard b/extras/integration_tests/sqflite/ios/Runner/Base.lproj/Main.storyboard similarity index 100% rename from extras/integration_tests/moor_flutter/ios/Runner/Base.lproj/Main.storyboard rename to extras/integration_tests/sqflite/ios/Runner/Base.lproj/Main.storyboard diff --git a/extras/integration_tests/moor_flutter/ios/Runner/Info.plist b/extras/integration_tests/sqflite/ios/Runner/Info.plist similarity index 100% rename from extras/integration_tests/moor_flutter/ios/Runner/Info.plist rename to extras/integration_tests/sqflite/ios/Runner/Info.plist diff --git a/extras/integration_tests/moor_flutter/ios/Runner/Runner-Bridging-Header.h b/extras/integration_tests/sqflite/ios/Runner/Runner-Bridging-Header.h similarity index 100% rename from extras/integration_tests/moor_flutter/ios/Runner/Runner-Bridging-Header.h rename to extras/integration_tests/sqflite/ios/Runner/Runner-Bridging-Header.h diff --git a/extras/integration_tests/moor_flutter/lib/moor_flutter.dart b/extras/integration_tests/sqflite/lib/drift_sqflite.dart similarity index 91% rename from extras/integration_tests/moor_flutter/lib/moor_flutter.dart rename to extras/integration_tests/sqflite/lib/drift_sqflite.dart index 78450a13..7c74f74e 100644 --- a/extras/integration_tests/moor_flutter/lib/moor_flutter.dart +++ b/extras/integration_tests/sqflite/lib/drift_sqflite.dart @@ -1,8 +1,8 @@ import 'dart:io'; +import 'package:drift_sqflite/drift_sqflite.dart'; import 'package:flutter/services.dart'; import 'package:flutter/widgets.dart' show WidgetsFlutterBinding; -import 'package:moor_flutter/moor_flutter.dart'; import 'package:path/path.dart'; import 'package:sqflite/sqflite.dart' show getDatabasesPath; import 'package:test/test.dart'; @@ -12,7 +12,7 @@ class SqfliteExecutor extends TestExecutor { @override DatabaseConnection createConnection() { return DatabaseConnection.fromExecutor( - FlutterQueryExecutor.inDatabaseFolder( + SqfliteQueryExecutor.inDatabaseFolder( path: 'app.db', singleInstance: false, ), @@ -44,7 +44,7 @@ Future main() async { } var didCallCreator = false; - final executor = FlutterQueryExecutor( + final executor = SqfliteQueryExecutor( path: dbFile.path, singleInstance: true, creator: (file) async { diff --git a/extras/integration_tests/moor_flutter/lib/encrypted_moor.dart b/extras/integration_tests/sqflite/lib/encrypted_moor.dart similarity index 100% rename from extras/integration_tests/moor_flutter/lib/encrypted_moor.dart rename to extras/integration_tests/sqflite/lib/encrypted_moor.dart diff --git a/extras/integration_tests/moor_flutter/pubspec.yaml b/extras/integration_tests/sqflite/pubspec.yaml similarity index 79% rename from extras/integration_tests/moor_flutter/pubspec.yaml rename to extras/integration_tests/sqflite/pubspec.yaml index 9ad92aae..b6f6e5f3 100644 --- a/extras/integration_tests/moor_flutter/pubspec.yaml +++ b/extras/integration_tests/sqflite/pubspec.yaml @@ -1,4 +1,4 @@ -name: moor_flutter_integration_test +name: drift_sqflite_integration_tests description: A new Flutter project. publish_to: 'none' version: 1.0.0+1 @@ -9,7 +9,8 @@ environment: dependencies: flutter: sdk: flutter - moor_flutter: + drift_sqflite: + path: ../../../drift_sqflite tests: path: ../tests encrypted_moor: @@ -28,4 +29,4 @@ dependency_overrides: flutter: assets: - - test_asset.db \ No newline at end of file + - test_asset.db diff --git a/extras/integration_tests/moor_flutter/test_asset.db b/extras/integration_tests/sqflite/test_asset.db similarity index 100% rename from extras/integration_tests/moor_flutter/test_asset.db rename to extras/integration_tests/sqflite/test_asset.db