mirror of https://github.com/AMT-Cheif/drift.git
Change integration tests' dialect to postgres
This commit is contained in:
parent
46454c28fb
commit
02ad0e8250
|
@ -20,7 +20,7 @@ targets:
|
|||
# features will be available. We depend on `sqlite3_flutter_libs`, which lets us use the latest
|
||||
# version with fts5 enabled.
|
||||
sql:
|
||||
dialect: sqlite
|
||||
dialect: postgres
|
||||
options:
|
||||
version: "3.38"
|
||||
modules: [fts5]
|
||||
|
|
|
@ -655,7 +655,7 @@ abstract class _$AppDatabase extends GeneratedDatabase {
|
|||
|
||||
Selectable<SearchResult> _search(String query) {
|
||||
return customSelect(
|
||||
'SELECT"todos"."id" AS "nested_0.id", "todos"."description" AS "nested_0.description", "todos"."category" AS "nested_0.category", "todos"."due_date" AS "nested_0.due_date","cat"."id" AS "nested_1.id", "cat"."name" AS "nested_1.name", "cat"."color" AS "nested_1.color" FROM text_entries INNER JOIN todo_entries AS todos ON todos.id = text_entries."rowid" LEFT OUTER JOIN categories AS cat ON cat.id = todos.category WHERE text_entries MATCH ?1 ORDER BY rank',
|
||||
'SELECT"todos"."id" AS "nested_0.id", "todos"."description" AS "nested_0.description", "todos"."category" AS "nested_0.category", "todos"."due_date" AS "nested_0.due_date","cat"."id" AS "nested_1.id", "cat"."name" AS "nested_1.name", "cat"."color" AS "nested_1.color" FROM text_entries INNER JOIN todo_entries AS todos ON todos.id = text_entries."rowid" LEFT OUTER JOIN categories AS cat ON cat.id = todos.category WHERE text_entries MATCH @1 ORDER BY rank',
|
||||
variables: [
|
||||
Variable<String>(query)
|
||||
],
|
||||
|
|
|
@ -8,6 +8,8 @@ targets:
|
|||
generate_values_in_copy_with: true
|
||||
named_parameters: true
|
||||
new_sql_code_generation: true
|
||||
sql:
|
||||
dialect: postgres
|
||||
build_web_compilers|entrypoint:
|
||||
generate_for:
|
||||
- web/**.dart
|
||||
|
|
|
@ -191,7 +191,7 @@ abstract class _$MyDatabase extends GeneratedDatabase {
|
|||
|
||||
Future<int> addEntry(String var1) {
|
||||
return customInsert(
|
||||
'INSERT INTO entries (text) VALUES (?1)',
|
||||
'INSERT INTO entries (text) VALUES (@1)',
|
||||
variables: [Variable<String>(var1)],
|
||||
updates: {entries},
|
||||
);
|
||||
|
|
|
@ -3,4 +3,7 @@ targets:
|
|||
builders:
|
||||
drift_dev:
|
||||
options:
|
||||
generate_connect_constructor: true
|
||||
generate_connect_constructor: true
|
||||
new_sql_code_generation: true
|
||||
sql:
|
||||
dialect: postgres
|
|
@ -557,7 +557,7 @@ class GroupCount extends ViewInfo<GroupCount, GroupCountData>
|
|||
String get entityName => 'group_count';
|
||||
@override
|
||||
String get createViewStmt =>
|
||||
'CREATE VIEW group_count AS SELECT\n users.*,\n (SELECT COUNT(*) FROM "groups" WHERE owner = users.id) AS group_count\n FROM users;';
|
||||
'CREATE VIEW group_count AS SELECT users.*, (SELECT COUNT(*) FROM "groups" WHERE owner = users.id) AS group_count FROM users';
|
||||
@override
|
||||
GroupCount get asDslTable => this;
|
||||
@override
|
||||
|
|
|
@ -37,6 +37,8 @@ targets:
|
|||
generate_values_in_copy_with: true
|
||||
named_parameters: true
|
||||
new_sql_code_generation: true
|
||||
sql:
|
||||
dialect: postgres
|
||||
build_web_compilers:entrypoint:
|
||||
generate_for:
|
||||
# This one is compiled in the other target
|
||||
|
|
|
@ -192,7 +192,7 @@ abstract class _$MyDatabase extends GeneratedDatabase {
|
|||
|
||||
Future<int> addEntry(String var1) {
|
||||
return customInsert(
|
||||
'INSERT INTO entries (text) VALUES (?1)',
|
||||
'INSERT INTO entries (text) VALUES (@1)',
|
||||
variables: [Variable<String>(var1)],
|
||||
updates: {entries},
|
||||
);
|
||||
|
|
|
@ -6,9 +6,9 @@ import 'package:postgres/postgres.dart';
|
|||
class PgDatabase extends DelegatedDatabase {
|
||||
/// Creates a drift database implementation from a postgres database
|
||||
/// [connection].
|
||||
PgDatabase(PostgreSQLConnection connection)
|
||||
PgDatabase(PostgreSQLConnection connection, {bool logStatements = false})
|
||||
: super(_PgDelegate(connection, connection),
|
||||
isSequential: true, logStatements: true);
|
||||
isSequential: true, logStatements: logStatements);
|
||||
|
||||
@override
|
||||
SqlDialect get dialect => SqlDialect.postgres;
|
||||
|
|
|
@ -15,7 +15,7 @@ targets:
|
|||
new_sql_code_generation: true
|
||||
scoped_dart_components: true
|
||||
sql:
|
||||
dialect: sqlite
|
||||
dialect: postgres
|
||||
options:
|
||||
version: "3.37"
|
||||
modules:
|
||||
|
|
|
@ -559,7 +559,7 @@ abstract class _$Database extends GeneratedDatabase {
|
|||
late final $FriendshipsTable friendships = $FriendshipsTable(this);
|
||||
Selectable<User> mostPopularUsers(int amount) {
|
||||
return customSelect(
|
||||
'SELECT * FROM users AS u ORDER BY (SELECT COUNT(*) FROM friendships WHERE first_user = u.id OR second_user = u.id) DESC LIMIT ?1',
|
||||
'SELECT * FROM users AS u ORDER BY (SELECT COUNT(*) FROM friendships WHERE first_user = u.id OR second_user = u.id) DESC LIMIT @1',
|
||||
variables: [
|
||||
Variable<int>(amount)
|
||||
],
|
||||
|
@ -571,7 +571,7 @@ abstract class _$Database extends GeneratedDatabase {
|
|||
|
||||
Selectable<int> amountOfGoodFriends(int user) {
|
||||
return customSelect(
|
||||
'SELECT COUNT(*) AS _c0 FROM friendships AS f WHERE f.really_good_friends = 1 AND(f.first_user = ?1 OR f.second_user = ?1)',
|
||||
'SELECT COUNT(*) AS _c0 FROM friendships AS f WHERE f.really_good_friends = 1 AND(f.first_user = @1 OR f.second_user = @1)',
|
||||
variables: [
|
||||
Variable<int>(user)
|
||||
],
|
||||
|
@ -582,7 +582,7 @@ abstract class _$Database extends GeneratedDatabase {
|
|||
|
||||
Selectable<FriendshipsOfResult> friendshipsOf(int user) {
|
||||
return customSelect(
|
||||
'SELECT f.really_good_friends,"user"."id" AS "nested_0.id", "user"."name" AS "nested_0.name", "user"."birth_date" AS "nested_0.birth_date", "user"."profile_picture" AS "nested_0.profile_picture", "user"."preferences" AS "nested_0.preferences" FROM friendships AS f INNER JOIN users AS user ON user.id IN (f.first_user, f.second_user) AND user.id != ?1 WHERE(f.first_user = ?1 OR f.second_user = ?1)',
|
||||
'SELECT f.really_good_friends,"user"."id" AS "nested_0.id", "user"."name" AS "nested_0.name", "user"."birth_date" AS "nested_0.birth_date", "user"."profile_picture" AS "nested_0.profile_picture", "user"."preferences" AS "nested_0.preferences" FROM friendships AS f INNER JOIN users AS "user" ON "user".id IN (f.first_user, f.second_user) AND "user".id != @1 WHERE(f.first_user = @1 OR f.second_user = @1)',
|
||||
variables: [
|
||||
Variable<int>(user)
|
||||
],
|
||||
|
@ -606,7 +606,7 @@ abstract class _$Database extends GeneratedDatabase {
|
|||
}
|
||||
|
||||
Selectable<Preferences?> settingsFor(int user) {
|
||||
return customSelect('SELECT preferences FROM users WHERE id = ?1',
|
||||
return customSelect('SELECT preferences FROM users WHERE id = @1',
|
||||
variables: [
|
||||
Variable<int>(user)
|
||||
],
|
||||
|
@ -631,7 +631,7 @@ abstract class _$Database extends GeneratedDatabase {
|
|||
|
||||
Future<List<Friendship>> returning(int var1, int var2, bool var3) {
|
||||
return customWriteReturning(
|
||||
'INSERT INTO friendships VALUES (?1, ?2, ?3) RETURNING *',
|
||||
'INSERT INTO friendships VALUES (@1, @2, @3) RETURNING *',
|
||||
variables: [
|
||||
Variable<int>(var1),
|
||||
Variable<int>(var2),
|
||||
|
|
|
@ -4,6 +4,7 @@ set -e
|
|||
function run_test() {
|
||||
echo "------------- Running test: $1 -------------"
|
||||
pushd $1 > /dev/null
|
||||
rm -rf .dart_tool
|
||||
dart pub upgrade
|
||||
dart format -o none --set-exit-if-changed .
|
||||
dart analyze --fatal-infos --fatal-warnings
|
||||
|
@ -21,6 +22,7 @@ function run_test() {
|
|||
function run_test_flutter() {
|
||||
echo "------------- Running flutter test: $1 -------------"
|
||||
pushd $1 > /dev/null
|
||||
rm -rf .dart_tool
|
||||
flutter pub upgrade
|
||||
flutter clean
|
||||
dart format -o none --set-exit-if-changed .
|
||||
|
|
Loading…
Reference in New Issue