Add test and changelog entry

This commit is contained in:
Simon Binder 2022-12-26 13:06:48 +01:00
parent 168a9bfa59
commit e02a814f5c
No known key found for this signature in database
GPG Key ID: 7891917E4147B8C0
2 changed files with 3 additions and 7 deletions

View File

@ -6,6 +6,7 @@
which tables are affected by the custom statement.
- For `STRICT` tables in drift files declaring a `ANY` column, drift will now
generate a mapping to the new `DriftAny` type.
- Add `likeExp` to generate `LIKE` expression with any comparison expression.
- Fix `UNIQUE` keys declared in drift files being written twice.
- Fix `customConstraints` not appearing in dumped database schema files.
- Work-around an issue causing complex migrations via `Migrator.alterTable` not to

View File

@ -1,20 +1,15 @@
import 'package:drift/drift.dart';
import 'package:test/test.dart';
import '../../generated/todos.dart';
import '../../test_utils/test_utils.dart';
void main() {
const expression =
CustomExpression<String>('col', precedence: Precedence.primary);
final db = TodoDb();
test('generates like expressions', () {
final ctx = GenerationContext.fromDb(db);
expression.like('pattern').writeInto(ctx);
expect(ctx.sql, 'col LIKE ?');
expect(ctx.boundVariables, ['pattern']);
expect(expression.like('pattern'), generates('col LIKE ?', ['pattern']));
expect(expression.likeExp(expression), generates('col LIKE col'));
});
test('generates regexp expressions', () {