mirror of https://github.com/AMT-Cheif/drift.git
Fix generation of PRIMARY KEY constraint on int column
This commit is contained in:
parent
77e444b13b
commit
89f3987e6b
|
@ -0,0 +1,38 @@
|
|||
import 'package:moor/src/runtime/components/component.dart';
|
||||
import 'package:test_api/test_api.dart';
|
||||
import 'package:moor/moor.dart';
|
||||
|
||||
import '../data/tables/todos.dart';
|
||||
|
||||
void main() {
|
||||
test('int column writes AUTOINCREMENT constraint', () {
|
||||
final column = GeneratedIntColumn(
|
||||
'foo',
|
||||
'tbl',
|
||||
false,
|
||||
declaredAsPrimaryKey: true,
|
||||
hasAutoIncrement: true,
|
||||
);
|
||||
|
||||
final context = GenerationContext.fromDb(TodoDb(null));
|
||||
column.writeColumnDefinition(context);
|
||||
|
||||
expect(
|
||||
context.sql, equals('foo INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT'));
|
||||
});
|
||||
|
||||
test('int column writes PRIMARY KEY constraint', () {
|
||||
final column = GeneratedIntColumn(
|
||||
'foo',
|
||||
'tbl',
|
||||
false,
|
||||
declaredAsPrimaryKey: true,
|
||||
hasAutoIncrement: false,
|
||||
);
|
||||
|
||||
final context = GenerationContext.fromDb(TodoDb(null));
|
||||
column.writeColumnDefinition(context);
|
||||
|
||||
expect(context.sql, equals('foo INTEGER NOT NULL PRIMARY KEY'));
|
||||
});
|
||||
}
|
Loading…
Reference in New Issue