Bump sqflite dependency, integration test for array args

This commit is contained in:
Simon Binder 2019-09-21 13:20:19 +02:00
parent b62ed05a87
commit 22dee72680
No known key found for this signature in database
GPG Key ID: 7891917E4147B8C0
9 changed files with 120 additions and 56 deletions

View File

@ -7,6 +7,7 @@ description: Example apps using moor
We have an [example in the repo](https://github.com/simolus3/moor/tree/master/moor_flutter/example), it's a simple todo list app,
written with moor.
written with moor. [Rody Davis](https://github.com/AppleEducate) has built a cleaner version of the example that works on all
Flutter platforms - including Web and Desktop! You can check it out [here](https://github.com/AppleEducate/moor_shared).
The [HackerNews reader app](https://github.com/filiph/hn_app) from the [Boring Flutter Show](https://www.youtube.com/playlist?list=PLjxrf2q8roU3ahJVrSgAnPjzkpGmL9Czl) also uses moor to keep a list of favorite articles.

View File

@ -7,7 +7,7 @@ packages:
name: analyzer
url: "https://pub.dartlang.org"
source: hosted
version: "0.36.4"
version: "0.38.3"
args:
dependency: transitive
description:
@ -21,14 +21,14 @@ packages:
name: async
url: "https://pub.dartlang.org"
source: hosted
version: "2.2.0"
version: "2.3.0"
boolean_selector:
dependency: transitive
description:
name: boolean_selector
url: "https://pub.dartlang.org"
source: hosted
version: "1.0.4"
version: "1.0.5"
charcode:
dependency: transitive
description:
@ -56,7 +56,7 @@ packages:
name: crypto
url: "https://pub.dartlang.org"
source: hosted
version: "2.0.6"
version: "2.1.3"
csslib:
dependency: transitive
description:
@ -75,7 +75,7 @@ packages:
name: front_end
url: "https://pub.dartlang.org"
source: hosted
version: "0.1.19"
version: "0.1.25"
glob:
dependency: transitive
description:
@ -131,21 +131,14 @@ packages:
name: json_annotation
url: "https://pub.dartlang.org"
source: hosted
version: "2.4.0"
json_rpc_2:
dependency: transitive
description:
name: json_rpc_2
url: "https://pub.dartlang.org"
source: hosted
version: "2.1.0"
version: "3.0.0"
kernel:
dependency: transitive
description:
name: kernel
url: "https://pub.dartlang.org"
source: hosted
version: "0.3.19"
version: "0.3.25"
matcher:
dependency: transitive
description:
@ -201,14 +194,14 @@ packages:
name: node_preamble
url: "https://pub.dartlang.org"
source: hosted
version: "1.4.5"
version: "1.4.8"
package_config:
dependency: transitive
description:
name: package_config
url: "https://pub.dartlang.org"
source: hosted
version: "1.0.5"
version: "1.1.0"
package_resolver:
dependency: transitive
description:
@ -222,14 +215,14 @@ packages:
name: path
url: "https://pub.dartlang.org"
source: hosted
version: "1.6.2"
version: "1.6.4"
pedantic:
dependency: transitive
description:
name: pedantic
url: "https://pub.dartlang.org"
source: hosted
version: "1.7.0"
version: "1.8.0+1"
pool:
dependency: transitive
description:
@ -304,7 +297,7 @@ packages:
name: sqflite
url: "https://pub.dartlang.org"
source: hosted
version: "1.1.6+2"
version: "1.1.6+5"
stack_trace:
dependency: transitive
description:
@ -325,7 +318,7 @@ packages:
name: string_scanner
url: "https://pub.dartlang.org"
source: hosted
version: "1.0.4"
version: "1.0.5"
synchronized:
dependency: transitive
description:
@ -346,21 +339,21 @@ packages:
name: test
url: "https://pub.dartlang.org"
source: hosted
version: "1.6.3"
version: "1.6.10"
test_api:
dependency: transitive
description:
name: test_api
url: "https://pub.dartlang.org"
source: hosted
version: "0.2.5"
version: "0.2.7"
test_core:
dependency: transitive
description:
name: test_core
url: "https://pub.dartlang.org"
source: hosted
version: "0.2.5"
version: "0.2.9+1"
tests:
dependency: "direct main"
description:
@ -382,13 +375,13 @@ packages:
url: "https://pub.dartlang.org"
source: hosted
version: "2.0.8"
vm_service_client:
vm_service:
dependency: transitive
description:
name: vm_service_client
name: vm_service
url: "https://pub.dartlang.org"
source: hosted
version: "0.2.6+2"
version: "2.0.0"
watcher:
dependency: transitive
description:
@ -402,14 +395,14 @@ packages:
name: web_socket_channel
url: "https://pub.dartlang.org"
source: hosted
version: "1.0.13"
version: "1.0.15"
yaml:
dependency: transitive
description:
name: yaml
url: "https://pub.dartlang.org"
source: hosted
version: "2.1.16"
version: "2.2.0"
sdks:
dart: ">=2.5.0-dev <2.6.0"
dart: ">=2.5.0-dev <=2.6.0-dev.1.0.flutter-7c1821c4aa"
flutter: ">=1.2.1 <2.0.0"

View File

@ -1,3 +0,0 @@
analyzer:
plugins:
- moor

View File

@ -75,6 +75,7 @@ class PreferenceConverter extends TypeConverter<Preferences, String> {
WHERE (f.first_user = :user OR f.second_user = :user)''',
'userCount': 'SELECT COUNT(id) FROM users',
'settingsFor': 'SELECT preferences FROM users WHERE id = :user',
'usersById': 'SELECT * FROM users WHERE id IN ?',
},
)
class Database extends _$Database {

View File

@ -21,7 +21,7 @@ Map<String, dynamic> _$PreferencesToJson(Preferences instance) =>
// MoorGenerator
// **************************************************************************
// ignore_for_file: unnecessary_brace_in_string_interps
// ignore_for_file: unnecessary_brace_in_string_interps, unnecessary_this
class User extends DataClass implements Insertable<User> {
final int id;
final String name;
@ -127,11 +127,11 @@ class User extends DataClass implements Insertable<User> {
bool operator ==(other) =>
identical(this, other) ||
(other is User &&
other.id == id &&
other.name == name &&
other.birthDate == birthDate &&
other.profilePicture == profilePicture &&
other.preferences == preferences);
other.id == this.id &&
other.name == this.name &&
other.birthDate == this.birthDate &&
other.profilePicture == this.profilePicture &&
other.preferences == this.preferences);
}
class UsersCompanion extends UpdateCompanion<User> {
@ -397,9 +397,9 @@ class Friendship extends DataClass implements Insertable<Friendship> {
bool operator ==(other) =>
identical(this, other) ||
(other is Friendship &&
other.firstUser == firstUser &&
other.secondUser == secondUser &&
other.reallyGoodFriends == reallyGoodFriends);
other.firstUser == this.firstUser &&
other.secondUser == this.secondUser &&
other.reallyGoodFriends == this.reallyGoodFriends);
}
class FriendshipsCompanion extends UpdateCompanion<Friendship> {
@ -630,6 +630,23 @@ abstract class _$Database extends GeneratedDatabase {
return settingsForQuery(user).watch();
}
Selectable<User> usersByIdQuery(List<int> var1) {
var $arrayStartIndex = 1;
final expandedvar1 = $expandVar($arrayStartIndex, var1.length);
$arrayStartIndex += var1.length;
return customSelectQuery('SELECT * FROM users WHERE id IN ($expandedvar1)',
variables: [for (var $ in var1) Variable.withInt($)],
readsFrom: {users}).map(_rowToUser);
}
Future<List<User>> usersById(List<int> var1) {
return usersByIdQuery(var1).get();
}
Stream<List<User>> watchUsersById(List<int> var1) {
return usersByIdQuery(var1).watch();
}
@override
List<TableInfo> get allTables => [users, friendships];
}

View File

@ -1,3 +0,0 @@
CREATE TABLE test (
id INT NOT NULL PRIMARY AUTOINCREMENT
)

View File

@ -23,4 +23,13 @@ void crudTests(TestExecutor executor) {
await db.makeFriends(a, b);
await expectation;
});
test('IN ? expressions can be expanded', () async {
// regression test for https://github.com/simolus3/moor/issues/156
final db = Database(executor.createExecutor());
final result = await db.usersById([1, 2, 3]);
expect(result.map((u) => u.name), ['Dash', 'Duke', 'Go Gopher']);
});
}

View File

@ -1,20 +1,34 @@
# Generated by pub
# See https://dart.dev/tools/pub/glossary#lockfile
packages:
archive:
dependency: transitive
description:
name: archive
url: "https://pub.dartlang.org"
source: hosted
version: "2.0.10"
args:
dependency: transitive
description:
name: args
url: "https://pub.dartlang.org"
source: hosted
version: "1.5.2"
async:
dependency: transitive
description:
name: async
url: "https://pub.dartlang.org"
source: hosted
version: "2.2.0"
version: "2.3.0"
boolean_selector:
dependency: transitive
description:
name: boolean_selector
url: "https://pub.dartlang.org"
source: hosted
version: "1.0.4"
version: "1.0.5"
charcode:
dependency: transitive
description:
@ -29,6 +43,20 @@ packages:
url: "https://pub.dartlang.org"
source: hosted
version: "1.14.11"
convert:
dependency: transitive
description:
name: convert
url: "https://pub.dartlang.org"
source: hosted
version: "2.1.1"
crypto:
dependency: transitive
description:
name: crypto
url: "https://pub.dartlang.org"
source: hosted
version: "2.1.3"
flutter:
dependency: "direct main"
description: flutter
@ -39,6 +67,13 @@ packages:
description: flutter
source: sdk
version: "0.0.0"
image:
dependency: transitive
description:
name: image
url: "https://pub.dartlang.org"
source: hosted
version: "2.1.4"
matcher:
dependency: transitive
description:
@ -52,35 +87,42 @@ packages:
name: meta
url: "https://pub.dartlang.org"
source: hosted
version: "1.1.6"
version: "1.1.7"
moor:
dependency: "direct main"
description:
path: "../moor"
relative: true
source: path
version: "1.7.1"
version: "1.7.2"
path:
dependency: "direct main"
description:
name: path
url: "https://pub.dartlang.org"
source: hosted
version: "1.6.2"
version: "1.6.4"
pedantic:
dependency: transitive
description:
name: pedantic
url: "https://pub.dartlang.org"
source: hosted
version: "1.7.0"
version: "1.8.0+1"
petitparser:
dependency: transitive
description:
name: petitparser
url: "https://pub.dartlang.org"
source: hosted
version: "2.4.0"
quiver:
dependency: transitive
description:
name: quiver
url: "https://pub.dartlang.org"
source: hosted
version: "2.0.3"
version: "2.0.5"
sky_engine:
dependency: transitive
description: flutter
@ -99,7 +141,7 @@ packages:
name: sqflite
url: "https://pub.dartlang.org"
source: hosted
version: "1.1.6+4"
version: "1.1.6+5"
stack_trace:
dependency: transitive
description:
@ -120,7 +162,7 @@ packages:
name: string_scanner
url: "https://pub.dartlang.org"
source: hosted
version: "1.0.4"
version: "1.0.5"
synchronized:
dependency: transitive
description:
@ -156,6 +198,13 @@ packages:
url: "https://pub.dartlang.org"
source: hosted
version: "2.0.8"
xml:
dependency: transitive
description:
name: xml
url: "https://pub.dartlang.org"
source: hosted
version: "3.5.0"
sdks:
dart: ">=2.2.2 <3.0.0"
dart: ">=2.4.0 <3.0.0"
flutter: ">=1.2.1 <2.0.0"

View File

@ -13,7 +13,7 @@ environment:
dependencies:
moor: ^1.7.0
sqflite: ^1.1.0
sqflite: ^1.1.6+5
meta: ^1.0.0
path: ^1.0.0
flutter: