mirror of https://github.com/AMT-Cheif/drift.git
parent
25c62e5677
commit
3a4dbef895
|
@ -3,9 +3,6 @@
|
||||||
- Add the `from(table)` method to generated databases. It can be used to write
|
- Add the `from(table)` method to generated databases. It can be used to write
|
||||||
common queries more concisely.
|
common queries more concisely.
|
||||||
- Make `groupConcat` nullable in the Dart API.
|
- Make `groupConcat` nullable in the Dart API.
|
||||||
- Throw an exception in a `NativeDatabase` when multiple statements are run in
|
|
||||||
a single call. In previous versions, parts of the SQL string would otherwise
|
|
||||||
be ignored.
|
|
||||||
|
|
||||||
## 1.2.0
|
## 1.2.0
|
||||||
|
|
||||||
|
|
|
@ -182,8 +182,7 @@ class _VmDelegate extends DatabaseDelegate {
|
||||||
@override
|
@override
|
||||||
Future<void> runBatched(BatchedStatements statements) async {
|
Future<void> runBatched(BatchedStatements statements) async {
|
||||||
final prepared = [
|
final prepared = [
|
||||||
for (final stmt in statements.statements)
|
for (final stmt in statements.statements) _db.prepare(stmt),
|
||||||
_db.prepare(stmt, checkNoTail: true),
|
|
||||||
];
|
];
|
||||||
|
|
||||||
for (final application in statements.arguments) {
|
for (final application in statements.arguments) {
|
||||||
|
@ -203,7 +202,7 @@ class _VmDelegate extends DatabaseDelegate {
|
||||||
if (args.isEmpty) {
|
if (args.isEmpty) {
|
||||||
_db.execute(statement);
|
_db.execute(statement);
|
||||||
} else {
|
} else {
|
||||||
final stmt = _db.prepare(statement, checkNoTail: true);
|
final stmt = _db.prepare(statement);
|
||||||
stmt.execute(args);
|
stmt.execute(args);
|
||||||
stmt.dispose();
|
stmt.dispose();
|
||||||
}
|
}
|
||||||
|
@ -228,7 +227,7 @@ class _VmDelegate extends DatabaseDelegate {
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Future<QueryResult> runSelect(String statement, List<Object?> args) async {
|
Future<QueryResult> runSelect(String statement, List<Object?> args) async {
|
||||||
final stmt = _db.prepare(statement, checkNoTail: true);
|
final stmt = _db.prepare(statement);
|
||||||
final result = stmt.select(args);
|
final result = stmt.select(args);
|
||||||
stmt.dispose();
|
stmt.dispose();
|
||||||
|
|
||||||
|
|
|
@ -386,10 +386,6 @@ abstract class DatabaseConnectionUser {
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Executes the custom sql [statement] on the database.
|
/// Executes the custom sql [statement] on the database.
|
||||||
///
|
|
||||||
/// [statement] should contain exactly one SQL statement. Attempting to run
|
|
||||||
/// multiple statements with a single [customStatement] may not be fully
|
|
||||||
/// supported on all platforms.
|
|
||||||
Future<void> customStatement(String statement, [List<dynamic>? args]) {
|
Future<void> customStatement(String statement, [List<dynamic>? args]) {
|
||||||
final engine = resolvedEngine;
|
final engine = resolvedEngine;
|
||||||
|
|
||||||
|
|
|
@ -25,40 +25,6 @@ void main() {
|
||||||
underlying.dispose();
|
underlying.dispose();
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
group('checks for trailing statement content', () {
|
|
||||||
late NativeDatabase db;
|
|
||||||
|
|
||||||
setUp(() async {
|
|
||||||
db = NativeDatabase.memory();
|
|
||||||
await db.ensureOpen(_FakeExecutorUser());
|
|
||||||
});
|
|
||||||
|
|
||||||
tearDown(() => db.close());
|
|
||||||
|
|
||||||
test('multiple statements are allowed for runCustom without args', () {
|
|
||||||
return db.runCustom('SELECT 1; SELECT 2;');
|
|
||||||
});
|
|
||||||
|
|
||||||
test('throws for runCustom with args', () async {
|
|
||||||
expect(db.runCustom('SELECT ?; SELECT ?;', [1, 2]), throwsArgumentError);
|
|
||||||
});
|
|
||||||
|
|
||||||
test('in runSelect', () async {
|
|
||||||
expect(db.runSelect('SELECT ?; SELECT ?;', [1, 2]), throwsArgumentError);
|
|
||||||
});
|
|
||||||
|
|
||||||
test('in runBatched', () {
|
|
||||||
expect(
|
|
||||||
db.runBatched(BatchedStatements([
|
|
||||||
'SELECT ?; SELECT ?;'
|
|
||||||
], [
|
|
||||||
ArgumentsForBatchedStatement(0, []),
|
|
||||||
])),
|
|
||||||
throwsArgumentError,
|
|
||||||
);
|
|
||||||
});
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
class _FakeExecutorUser extends QueryExecutorUser {
|
class _FakeExecutorUser extends QueryExecutorUser {
|
||||||
|
|
Loading…
Reference in New Issue