mirror of https://github.com/AMT-Cheif/drift.git
add new table with every type of column for tests
This commit is contained in:
parent
3bd837517c
commit
14335b5d3d
|
@ -24,9 +24,6 @@ class TodosTable extends Table with AutoIncrement {
|
||||||
@JsonKey('target_date')
|
@JsonKey('target_date')
|
||||||
DateTimeColumn get targetDate => dateTime().nullable().unique()();
|
DateTimeColumn get targetDate => dateTime().nullable().unique()();
|
||||||
|
|
||||||
RealColumn get someFloat => real().nullable()();
|
|
||||||
Int64Column get someInt64 => int64().nullable()();
|
|
||||||
|
|
||||||
IntColumn get category => integer().references(Categories, #id).nullable()();
|
IntColumn get category => integer().references(Categories, #id).nullable()();
|
||||||
|
|
||||||
TextColumn get status => textEnum<TodoStatus>().nullable()();
|
TextColumn get status => textEnum<TodoStatus>().nullable()();
|
||||||
|
@ -90,6 +87,22 @@ class TableWithoutPK extends Table {
|
||||||
text().map(const CustomConverter()).clientDefault(_uuid.v4)();
|
text().map(const CustomConverter()).clientDefault(_uuid.v4)();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
class TableWithEveryColumnType extends Table with AutoIncrement {
|
||||||
|
BoolColumn get aBool => boolean().nullable()();
|
||||||
|
DateTimeColumn get aDateTime => dateTime().nullable()();
|
||||||
|
TextColumn get aText => text().nullable()();
|
||||||
|
IntColumn get anInt => integer().nullable()();
|
||||||
|
Int64Column get anInt64 => int64().nullable()();
|
||||||
|
RealColumn get aReal => real().nullable()();
|
||||||
|
BlobColumn get aBlob => blob().nullable()();
|
||||||
|
IntColumn get anIntEnum => intEnum<TodoStatus>().nullable()();
|
||||||
|
TextColumn get aTextWithConverter => text()
|
||||||
|
.named('insert')
|
||||||
|
.map(const CustomJsonConverter())
|
||||||
|
.nullable()
|
||||||
|
.nullable()();
|
||||||
|
}
|
||||||
|
|
||||||
class CustomRowClass {
|
class CustomRowClass {
|
||||||
final int notReallyAnId;
|
final int notReallyAnId;
|
||||||
final double anotherName;
|
final double anotherName;
|
||||||
|
@ -251,6 +264,7 @@ const uuidType = DialectAwareSqlType<UuidValue>.via(
|
||||||
TableWithoutPK,
|
TableWithoutPK,
|
||||||
PureDefaults,
|
PureDefaults,
|
||||||
WithCustomType,
|
WithCustomType,
|
||||||
|
TableWithEveryColumnType
|
||||||
],
|
],
|
||||||
views: [
|
views: [
|
||||||
CategoryTodoCountView,
|
CategoryTodoCountView,
|
||||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -23,246 +23,256 @@ void main() {
|
||||||
// (o) => o(priority: Value(CategoryPriority.high), description: "Other"));
|
// (o) => o(priority: Value(CategoryPriority.high), description: "Other"));
|
||||||
|
|
||||||
// // School
|
// // School
|
||||||
// await db.managers.todosTable.create((o) => o(
|
// await db.managers.tableWithEveryColumnType.create((o) => o(
|
||||||
// content: "Get that math homework done",
|
// aText: Value("Get that math homework done"),
|
||||||
// title: Value("Math Homework"),
|
// title: Value("Math Homework"),
|
||||||
// category: Value(schoolId),
|
// category: Value(schoolId),
|
||||||
// status: Value(TodoStatus.open),
|
// anIntEnum: Value(TodoStatus.open),
|
||||||
// targetDate: Value(DateTime.now().add(Duration(days: 1,seconds: 10)))));
|
// aDateTime: Value(DateTime.now().add(Duration(days: 1,seconds: 10)))));
|
||||||
// await db.managers.todosTable.create((o) => o(
|
// await db.managers.tableWithEveryColumnType.create((o) => o(
|
||||||
// content: "Finish that report",
|
// aText: "Finish that report",
|
||||||
// title: Value("Report"),
|
// title: Value("Report"),
|
||||||
// category: Value(workId),
|
// category: Value(workId),
|
||||||
// status: Value(TodoStatus.workInProgress),
|
// anIntEnum: Value(TodoStatus.workInProgress),
|
||||||
// targetDate: Value(DateTime.now().add(Duration(days: 2,seconds: 10)))));
|
// aDateTime: Value(DateTime.now().add(Duration(days: 2,seconds: 10)))));
|
||||||
// await db.managers.todosTable.create((o) => o(
|
// await db.managers.tableWithEveryColumnType.create((o) => o(
|
||||||
// content: "Get that english homework done",
|
// aText: "Get that english homework done",
|
||||||
// title: Value("English Homework"),
|
// title: Value("English Homework"),
|
||||||
// category: Value(schoolId),
|
// category: Value(schoolId),
|
||||||
// status: Value(TodoStatus.open),
|
// anIntEnum: Value(TodoStatus.open),
|
||||||
// targetDate: Value(DateTime.now().add(Duration(days: 1,seconds: 15)))));
|
// aDateTime: Value(DateTime.now().add(Duration(days: 1,seconds: 15)))));
|
||||||
// await db.managers.todosTable.create((o) => o(
|
// await db.managers.tableWithEveryColumnType.create((o) => o(
|
||||||
// content: "Finish that Book report",
|
// aText: "Finish that Book report",
|
||||||
// title: Value("Book Report"),
|
// title: Value("Book Report"),
|
||||||
// category: Value(workId),
|
// category: Value(workId),
|
||||||
// status: Value(TodoStatus.done),
|
// anIntEnum: Value(TodoStatus.done),
|
||||||
// targetDate: Value(DateTime.now().subtract(Duration(days: 2,seconds: 15)))));
|
// aDateTime: Value(DateTime.now().subtract(Duration(days: 2,seconds: 15)))));
|
||||||
|
|
||||||
// // Work
|
// // Work
|
||||||
// await db.managers.todosTable.create((o) => o(
|
// await db.managers.tableWithEveryColumnType.create((o) => o(
|
||||||
// content: "File those reports",
|
// aText: "File those reports",
|
||||||
// title: Value("File Reports"),
|
// title: Value("File Reports"),
|
||||||
// category: Value(workId),
|
// category: Value(workId),
|
||||||
// status: Value(TodoStatus.open),
|
// anIntEnum: Value(TodoStatus.open),
|
||||||
// targetDate: Value(DateTime.now().add(Duration(days: 1, seconds: 20)))););
|
// aDateTime: Value(DateTime.now().add(Duration(days: 1, seconds: 20)))););
|
||||||
// await db.managers.todosTable.create((o) => o(
|
// await db.managers.tableWithEveryColumnType.create((o) => o(
|
||||||
// content: "Clean the office",
|
// aText: "Clean the office",
|
||||||
// title: Value("Clean Office"),
|
// title: Value("Clean Office"),
|
||||||
// category: Value(workId),
|
// category: Value(workId),
|
||||||
// status: Value(TodoStatus.workInProgress),
|
// anIntEnum: Value(TodoStatus.workInProgress),
|
||||||
// targetDate: Value(DateTime.now().add(Duration(days: 2, seconds: 20)))););
|
// aDateTime: Value(DateTime.now().add(Duration(days: 2, seconds: 20)))););
|
||||||
// await db.managers.todosTable.create((o) => o(
|
// await db.managers.tableWithEveryColumnType.create((o) => o(
|
||||||
// content: "Nail that presentation",
|
// aText: "Nail that presentation",
|
||||||
// title: Value("Presentation"),
|
// title: Value("Presentation"),
|
||||||
// category: Value(workId),
|
// category: Value(workId),
|
||||||
// status: Value(TodoStatus.open),
|
// anIntEnum: Value(TodoStatus.open),
|
||||||
// targetDate: Value(DateTime.now().add(Duration(days: 1, seconds: 25)))));
|
// aDateTime: Value(DateTime.now().add(Duration(days: 1, seconds: 25)))));
|
||||||
// await db.managers.todosTable.create((o) => o(
|
// await db.managers.tableWithEveryColumnType.create((o) => o(
|
||||||
// content: "Take a break",
|
// aText: "Take a break",
|
||||||
// title: Value("Break"),
|
// title: Value("Break"),
|
||||||
// category: Value(workId),
|
// category: Value(workId),
|
||||||
// status: Value(TodoStatus.done),
|
// anIntEnum: Value(TodoStatus.done),
|
||||||
// targetDate: Value(DateTime.now().subtract(Duration(days: 2, seconds: 25)))));
|
// aDateTime: Value(DateTime.now().subtract(Duration(days: 2, seconds: 25)))));
|
||||||
|
|
||||||
// // Work
|
// // Work
|
||||||
// await db.managers.todosTable.create((o) => o(
|
// await db.managers.tableWithEveryColumnType.create((o) => o(
|
||||||
// content: "Take out the trash",
|
// aText: "Take out the trash",
|
||||||
// title: Value("Trash"),
|
// title: Value("Trash"),
|
||||||
// category: Value(homeId),
|
// category: Value(homeId),
|
||||||
// status: Value(TodoStatus.open),
|
// anIntEnum: Value(TodoStatus.open),
|
||||||
// targetDate: Value(DateTime.now().add(Duration(days: 1, seconds: 30)))););
|
// aDateTime: Value(DateTime.now().add(Duration(days: 1, seconds: 30)))););
|
||||||
// await db.managers.todosTable.create((o) => o(
|
// await db.managers.tableWithEveryColumnType.create((o) => o(
|
||||||
// content: "Mow the lawn",
|
// aText: "Mow the lawn",
|
||||||
// title: Value("Lawn"),
|
// title: Value("Lawn"),
|
||||||
// category: Value(homeId),
|
// category: Value(homeId),
|
||||||
// status: Value(TodoStatus.workInProgress),
|
// anIntEnum: Value(TodoStatus.workInProgress),
|
||||||
// targetDate: Value(DateTime.now().add(Duration(days: 2, seconds: 30)))));
|
// aDateTime: Value(DateTime.now().add(Duration(days: 2, seconds: 30)))));
|
||||||
// await db.managers.todosTable.create((o) => o(
|
// await db.managers.tableWithEveryColumnType.create((o) => o(
|
||||||
// content: "Fix the sink",
|
// aText: "Fix the sink",
|
||||||
// title: Value("Sink"),
|
// title: Value("Sink"),
|
||||||
// category: Value(homeId),
|
// category: Value(homeId),
|
||||||
// status: Value(TodoStatus.open),
|
// anIntEnum: Value(TodoStatus.open),
|
||||||
// targetDate: Value(DateTime.now().add(Duration(days: 1, seconds: 35)))););
|
// aDateTime: Value(DateTime.now().add(Duration(days: 1, seconds: 35)))););
|
||||||
// await db.managers.todosTable.create((o) => o(
|
// await db.managers.tableWithEveryColumnType.create((o) => o(
|
||||||
// content: "Paint the walls",
|
// aText: "Paint the walls",
|
||||||
// title: Value("Paint"),
|
// title: Value("Paint"),
|
||||||
// category: Value(homeId),
|
// category: Value(homeId),
|
||||||
// status: Value(TodoStatus.done),
|
// anIntEnum: Value(TodoStatus.done),
|
||||||
// targetDate: Value(DateTime.now().subtract(Duration(days: 2, seconds: 35)))));
|
// aDateTime: Value(DateTime.now().subtract(Duration(days: 2, seconds: 35)))));
|
||||||
|
|
||||||
// // Other
|
// // Other
|
||||||
// await db.managers.todosTable.create((o) => o(
|
// await db.managers.tableWithEveryColumnType.create((o) => o(
|
||||||
// content: "Get groceries",
|
// aText: "Get groceries",
|
||||||
// title: Value("Groceries"),
|
// title: Value("Groceries"),
|
||||||
// category: Value(otherId),
|
// category: Value(otherId),
|
||||||
// status: Value(TodoStatus.open),
|
// anIntEnum: Value(TodoStatus.open),
|
||||||
// targetDate: Value(DateTime.now().add(Duration(days: 1, seconds: 40)))););
|
// aDateTime: Value(DateTime.now().add(Duration(days: 1, seconds: 40)))););
|
||||||
// await db.managers.todosTable.create((o) => o(
|
// await db.managers.tableWithEveryColumnType.create((o) => o(
|
||||||
// content: "Pick up the kids",
|
// aText: "Pick up the kids",
|
||||||
// title: Value("Kids"),
|
// title: Value("Kids"),
|
||||||
// category: Value(otherId),
|
// category: Value(otherId),
|
||||||
// status: Value(TodoStatus.workInProgress),
|
// anIntEnum: Value(TodoStatus.workInProgress),
|
||||||
// targetDate: Value(DateTime.now().add(Duration(days: 2, seconds: 40)))););
|
// aDateTime: Value(DateTime.now().add(Duration(days: 2, seconds: 40)))););
|
||||||
// await db.managers.todosTable.create((o) => o(
|
// await db.managers.tableWithEveryColumnType.create((o) => o(
|
||||||
// content: "Take the dog for a walk",
|
// aText: "Take the dog for a walk",
|
||||||
// title: Value("Dog"),
|
// title: Value("Dog"),
|
||||||
// category: Value(otherId),
|
// category: Value(otherId),
|
||||||
// status: Value(TodoStatus.open),
|
// anIntEnum: Value(TodoStatus.open),
|
||||||
// targetDate: Value(DateTime.now().add(Duration(days: 1, seconds: 45)))));
|
// aDateTime: Value(DateTime.now().add(Duration(days: 1, seconds: 45)))));
|
||||||
|
|
||||||
// // Items with no category
|
// // Items with no category
|
||||||
// await db.managers.todosTable.create((o) => o(
|
// await db.managers.tableWithEveryColumnType.create((o) => o(
|
||||||
// content: "Get Whiteboard",
|
// aText: "Get Whiteboard",
|
||||||
// title: Value("Whiteboard"),
|
// title: Value("Whiteboard"),
|
||||||
// status: Value(TodoStatus.open),
|
// anIntEnum: Value(TodoStatus.open),
|
||||||
// targetDate: Value(DateTime.now().add(Duration(days: 1, seconds: 50)))););
|
// aDateTime: Value(DateTime.now().add(Duration(days: 1, seconds: 50)))););
|
||||||
// await db.managers.todosTable.create((o) => o(
|
// await db.managers.tableWithEveryColumnType.create((o) => o(
|
||||||
// content: "Drink Water",
|
// aText: "Drink Water",
|
||||||
// title: Value("Water"),
|
// title: Value("Water"),
|
||||||
// status: Value(TodoStatus.workInProgress),
|
// anIntEnum: Value(TodoStatus.workInProgress),
|
||||||
// targetDate: Value(DateTime.now().add(Duration(days: 2, seconds: 50)))));
|
// aDateTime: Value(DateTime.now().add(Duration(days: 2, seconds: 50)))));
|
||||||
// });
|
// });
|
||||||
|
|
||||||
tearDown(() => db.close());
|
tearDown(() => db.close());
|
||||||
|
|
||||||
test('manager - query generic', () async {
|
test('manager - query generic', () async {
|
||||||
await db.managers.todosTable.create((o) => o(
|
await db.managers.tableWithEveryColumnType.create((o) => o(
|
||||||
content: "Get that math homework done",
|
aText: Value("Get that math homework done"),
|
||||||
status: Value(TodoStatus.open),
|
anIntEnum: Value(TodoStatus.open),
|
||||||
someFloat: Value(5.0),
|
aReal: Value(5.0),
|
||||||
targetDate: Value(DateTime.now().add(Duration(days: 1)))));
|
aDateTime: Value(DateTime.now().add(Duration(days: 1)))));
|
||||||
await db.managers.todosTable.create((o) => o(
|
await db.managers.tableWithEveryColumnType.create((o) => o(
|
||||||
content: "Get that math homework done",
|
aText: Value("Get that math homework done"),
|
||||||
status: Value(TodoStatus.open),
|
anIntEnum: Value(TodoStatus.open),
|
||||||
targetDate: Value(DateTime.now().add(Duration(days: 2)))));
|
aDateTime: Value(DateTime.now().add(Duration(days: 2)))));
|
||||||
await db.managers.todosTable.create((o) => o(
|
await db.managers.tableWithEveryColumnType.create((o) => o(
|
||||||
content: "Get that math homework done",
|
aText: Value("Get that math homework done"),
|
||||||
status: Value(TodoStatus.open),
|
anIntEnum: Value(TodoStatus.open),
|
||||||
someFloat: Value(3.0),
|
aReal: Value(3.0),
|
||||||
targetDate: Value(DateTime.now().add(Duration(days: 3)))));
|
aDateTime: Value(DateTime.now().add(Duration(days: 3)))));
|
||||||
|
|
||||||
// Equals
|
// Equals
|
||||||
expect(
|
expect(
|
||||||
db.managers.todosTable.filter((f) => f.someFloat.equals(5.0)).count(),
|
db.managers.tableWithEveryColumnType
|
||||||
|
.filter((f) => f.aReal.equals(5.0))
|
||||||
|
.count(),
|
||||||
completion(1));
|
completion(1));
|
||||||
expect(db.managers.todosTable.filter((f) => f.someFloat(3.0)).count(),
|
expect(
|
||||||
|
db.managers.tableWithEveryColumnType
|
||||||
|
.filter((f) => f.aReal(3.0))
|
||||||
|
.count(),
|
||||||
completion(1));
|
completion(1));
|
||||||
// In
|
// In
|
||||||
expect(
|
expect(
|
||||||
db.managers.todosTable
|
db.managers.tableWithEveryColumnType
|
||||||
.filter((f) => f.someFloat.isIn([3.0, 5.0]))
|
.filter((f) => f.aReal.isIn([3.0, 5.0]))
|
||||||
.count(),
|
.count(),
|
||||||
completion(2));
|
completion(2));
|
||||||
|
|
||||||
// Not In
|
// Not In
|
||||||
expect(
|
expect(
|
||||||
db.managers.todosTable
|
db.managers.tableWithEveryColumnType
|
||||||
.filter((f) => f.someFloat.isNotIn([3.0, 5.0]))
|
.filter((f) => f.aReal.isNotIn([3.0, 5.0]))
|
||||||
.count(),
|
.count(),
|
||||||
completion(0));
|
completion(0));
|
||||||
|
|
||||||
// Null check
|
// Null check
|
||||||
expect(db.managers.todosTable.filter((f) => f.someFloat.isNull()).count(),
|
expect(
|
||||||
|
db.managers.tableWithEveryColumnType
|
||||||
|
.filter((f) => f.aReal.isNull())
|
||||||
|
.count(),
|
||||||
completion(1));
|
completion(1));
|
||||||
expect(
|
expect(
|
||||||
db.managers.todosTable.filter((f) => f.someFloat.isNotNull()).count(),
|
db.managers.tableWithEveryColumnType
|
||||||
|
.filter((f) => f.aReal.isNotNull())
|
||||||
|
.count(),
|
||||||
completion(2));
|
completion(2));
|
||||||
});
|
});
|
||||||
|
|
||||||
test('manager - query number', () async {
|
test('manager - query number', () async {
|
||||||
await db.managers.todosTable.create((o) => o(
|
await db.managers.tableWithEveryColumnType.create((o) => o(
|
||||||
content: "Get that math homework done",
|
aText: Value("Get that math homework done"),
|
||||||
status: Value(TodoStatus.open),
|
anIntEnum: Value(TodoStatus.open),
|
||||||
someFloat: Value(5.0),
|
aReal: Value(5.0),
|
||||||
targetDate: Value(DateTime.now().add(Duration(days: 1)))));
|
aDateTime: Value(DateTime.now().add(Duration(days: 1)))));
|
||||||
await db.managers.todosTable.create((o) => o(
|
await db.managers.tableWithEveryColumnType.create((o) => o(
|
||||||
content: "Get that math homework done",
|
aText: Value("Get that math homework done"),
|
||||||
status: Value(TodoStatus.open),
|
anIntEnum: Value(TodoStatus.open),
|
||||||
targetDate: Value(DateTime.now().add(Duration(days: 2)))));
|
aDateTime: Value(DateTime.now().add(Duration(days: 2)))));
|
||||||
await db.managers.todosTable.create((o) => o(
|
await db.managers.tableWithEveryColumnType.create((o) => o(
|
||||||
content: "Get that math homework done",
|
aText: Value("Get that math homework done"),
|
||||||
status: Value(TodoStatus.open),
|
anIntEnum: Value(TodoStatus.open),
|
||||||
someFloat: Value(3.0),
|
aReal: Value(3.0),
|
||||||
targetDate: Value(DateTime.now().add(Duration(days: 3)))));
|
aDateTime: Value(DateTime.now().add(Duration(days: 3)))));
|
||||||
|
|
||||||
// More than
|
// More than
|
||||||
expect(
|
expect(
|
||||||
db.managers.todosTable
|
db.managers.tableWithEveryColumnType
|
||||||
.filter((f) => f.someFloat.isBiggerThan(3.0))
|
.filter((f) => f.aReal.isBiggerThan(3.0))
|
||||||
.count(),
|
.count(),
|
||||||
completion(1));
|
completion(1));
|
||||||
expect(
|
expect(
|
||||||
db.managers.todosTable
|
db.managers.tableWithEveryColumnType
|
||||||
.filter((f) => f.someFloat.isBiggerOrEqualTo(3.0))
|
.filter((f) => f.aReal.isBiggerOrEqualTo(3.0))
|
||||||
.count(),
|
.count(),
|
||||||
completion(2));
|
completion(2));
|
||||||
|
|
||||||
// Less than
|
// Less than
|
||||||
expect(
|
expect(
|
||||||
db.managers.todosTable
|
db.managers.tableWithEveryColumnType
|
||||||
.filter((f) => f.someFloat.isSmallerThan(5.0))
|
.filter((f) => f.aReal.isSmallerThan(5.0))
|
||||||
.count(),
|
.count(),
|
||||||
completion(1));
|
completion(1));
|
||||||
expect(
|
expect(
|
||||||
db.managers.todosTable
|
db.managers.tableWithEveryColumnType
|
||||||
.filter((f) => f.someFloat.isSmallerOrEqualTo(5.0))
|
.filter((f) => f.aReal.isSmallerOrEqualTo(5.0))
|
||||||
.count(),
|
.count(),
|
||||||
completion(2));
|
completion(2));
|
||||||
|
|
||||||
// Between
|
// Between
|
||||||
expect(
|
expect(
|
||||||
db.managers.todosTable
|
db.managers.tableWithEveryColumnType
|
||||||
.filter((f) => f.someFloat.isBetween(3.0, 5.0))
|
.filter((f) => f.aReal.isBetween(3.0, 5.0))
|
||||||
.count(),
|
.count(),
|
||||||
completion(2));
|
completion(2));
|
||||||
expect(
|
expect(
|
||||||
db.managers.todosTable
|
db.managers.tableWithEveryColumnType
|
||||||
.filter((f) => f.someFloat.isNotBetween(3.0, 5.0))
|
.filter((f) => f.aReal.isNotBetween(3.0, 5.0))
|
||||||
.count(),
|
.count(),
|
||||||
completion(0));
|
completion(0));
|
||||||
});
|
});
|
||||||
|
|
||||||
test('manager - query string', () async {
|
test('manager - query string', () async {
|
||||||
await db.managers.todosTable.create((o) => o(
|
await db.managers.tableWithEveryColumnType.create((o) => o(
|
||||||
content: "Get that math homework done",
|
aText: Value("Get that math homework done"),
|
||||||
status: Value(TodoStatus.open),
|
anIntEnum: Value(TodoStatus.open),
|
||||||
));
|
));
|
||||||
await db.managers.todosTable.create((o) => o(
|
await db.managers.tableWithEveryColumnType.create((o) => o(
|
||||||
content: "That homework Done",
|
aText: Value("That homework Done"),
|
||||||
));
|
));
|
||||||
await db.managers.todosTable.create((o) => o(
|
await db.managers.tableWithEveryColumnType.create((o) => o(
|
||||||
content: "that MATH homework",
|
aText: Value("that MATH homework"),
|
||||||
status: Value(TodoStatus.open),
|
anIntEnum: Value(TodoStatus.open),
|
||||||
));
|
));
|
||||||
|
|
||||||
// StartsWith
|
// StartsWith
|
||||||
expect(
|
expect(
|
||||||
db.managers.todosTable
|
db.managers.tableWithEveryColumnType
|
||||||
.filter((f) => f.content.startsWith("that"))
|
.filter((f) => f.aText.startsWith("that"))
|
||||||
.count(),
|
.count(),
|
||||||
completion(2));
|
completion(2));
|
||||||
|
|
||||||
// EndsWith
|
// EndsWith
|
||||||
expect(
|
expect(
|
||||||
db.managers.todosTable
|
db.managers.tableWithEveryColumnType
|
||||||
.filter((f) => f.content.endsWith("done"))
|
.filter((f) => f.aText.endsWith("done"))
|
||||||
.count(),
|
.count(),
|
||||||
completion(2));
|
completion(2));
|
||||||
|
|
||||||
// Contains
|
// Contains
|
||||||
expect(
|
expect(
|
||||||
db.managers.todosTable
|
db.managers.tableWithEveryColumnType
|
||||||
.filter((f) => f.content.contains("math"))
|
.filter((f) => f.aText.contains("math"))
|
||||||
.count(),
|
.count(),
|
||||||
completion(2));
|
completion(2));
|
||||||
|
|
||||||
|
@ -271,77 +281,77 @@ void main() {
|
||||||
|
|
||||||
// StartsWith
|
// StartsWith
|
||||||
expect(
|
expect(
|
||||||
db.managers.todosTable
|
db.managers.tableWithEveryColumnType
|
||||||
.filter((f) => f.content.startsWith("that", caseInsensitive: false))
|
.filter((f) => f.aText.startsWith("that", caseInsensitive: false))
|
||||||
.count(),
|
.count(),
|
||||||
completion(1));
|
completion(1));
|
||||||
|
|
||||||
// EndsWith
|
// EndsWith
|
||||||
expect(
|
expect(
|
||||||
db.managers.todosTable
|
db.managers.tableWithEveryColumnType
|
||||||
.filter((f) => f.content.endsWith("done", caseInsensitive: false))
|
.filter((f) => f.aText.endsWith("done", caseInsensitive: false))
|
||||||
.count(),
|
.count(),
|
||||||
completion(1));
|
completion(1));
|
||||||
|
|
||||||
// Contains
|
// Contains
|
||||||
expect(
|
expect(
|
||||||
db.managers.todosTable
|
db.managers.tableWithEveryColumnType
|
||||||
.filter((f) => f.content.contains("math", caseInsensitive: false))
|
.filter((f) => f.aText.contains("math", caseInsensitive: false))
|
||||||
.count(),
|
.count(),
|
||||||
completion(1));
|
completion(1));
|
||||||
});
|
});
|
||||||
|
|
||||||
test('manager - query int64', () async {
|
test('manager - query int64', () async {
|
||||||
await db.managers.todosTable.create((o) => o(
|
await db.managers.tableWithEveryColumnType.create((o) => o(
|
||||||
content: "Get that math homework done",
|
aText: Value("Get that math homework done"),
|
||||||
status: Value(TodoStatus.open),
|
anIntEnum: Value(TodoStatus.open),
|
||||||
someInt64: Value(BigInt.from(5.0)),
|
anInt64: Value(BigInt.from(5.0)),
|
||||||
targetDate: Value(DateTime.now().add(Duration(days: 1)))));
|
aDateTime: Value(DateTime.now().add(Duration(days: 1)))));
|
||||||
await db.managers.todosTable.create((o) => o(
|
await db.managers.tableWithEveryColumnType.create((o) => o(
|
||||||
content: "Get that math homework done",
|
aText: Value("Get that math homework done"),
|
||||||
status: Value(TodoStatus.open),
|
anIntEnum: Value(TodoStatus.open),
|
||||||
targetDate: Value(DateTime.now().add(Duration(days: 2)))));
|
aDateTime: Value(DateTime.now().add(Duration(days: 2)))));
|
||||||
await db.managers.todosTable.create((o) => o(
|
await db.managers.tableWithEveryColumnType.create((o) => o(
|
||||||
content: "Get that math homework done",
|
aText: Value("Get that math homework done"),
|
||||||
status: Value(TodoStatus.open),
|
anIntEnum: Value(TodoStatus.open),
|
||||||
someInt64: Value(BigInt.from(3.0)),
|
anInt64: Value(BigInt.from(3.0)),
|
||||||
targetDate: Value(DateTime.now().add(Duration(days: 3)))));
|
aDateTime: Value(DateTime.now().add(Duration(days: 3)))));
|
||||||
|
|
||||||
// More than
|
// More than
|
||||||
expect(
|
expect(
|
||||||
db.managers.todosTable
|
db.managers.tableWithEveryColumnType
|
||||||
.filter((f) => f.someInt64.isBiggerThan(BigInt.from(3.0)))
|
.filter((f) => f.anInt64.isBiggerThan(BigInt.from(3.0)))
|
||||||
.count(),
|
.count(),
|
||||||
completion(1));
|
completion(1));
|
||||||
expect(
|
expect(
|
||||||
db.managers.todosTable
|
db.managers.tableWithEveryColumnType
|
||||||
.filter((f) => f.someInt64.isBiggerOrEqualTo(BigInt.from(3.0)))
|
.filter((f) => f.anInt64.isBiggerOrEqualTo(BigInt.from(3.0)))
|
||||||
.count(),
|
.count(),
|
||||||
completion(2));
|
completion(2));
|
||||||
|
|
||||||
// Less than
|
// Less than
|
||||||
expect(
|
expect(
|
||||||
db.managers.todosTable
|
db.managers.tableWithEveryColumnType
|
||||||
.filter((f) => f.someInt64.isSmallerThan(BigInt.from(5.0)))
|
.filter((f) => f.anInt64.isSmallerThan(BigInt.from(5.0)))
|
||||||
.count(),
|
.count(),
|
||||||
completion(1));
|
completion(1));
|
||||||
expect(
|
expect(
|
||||||
db.managers.todosTable
|
db.managers.tableWithEveryColumnType
|
||||||
.filter((f) => f.someInt64.isSmallerOrEqualTo(BigInt.from(5.0)))
|
.filter((f) => f.anInt64.isSmallerOrEqualTo(BigInt.from(5.0)))
|
||||||
.count(),
|
.count(),
|
||||||
completion(2));
|
completion(2));
|
||||||
|
|
||||||
// Between
|
// Between
|
||||||
expect(
|
expect(
|
||||||
db.managers.todosTable
|
db.managers.tableWithEveryColumnType
|
||||||
.filter((f) =>
|
.filter(
|
||||||
f.someInt64.isBetween(BigInt.from(3.0), BigInt.from(5.0)))
|
(f) => f.anInt64.isBetween(BigInt.from(3.0), BigInt.from(5.0)))
|
||||||
.count(),
|
.count(),
|
||||||
completion(2));
|
completion(2));
|
||||||
expect(
|
expect(
|
||||||
db.managers.todosTable
|
db.managers.tableWithEveryColumnType
|
||||||
.filter((f) =>
|
.filter((f) =>
|
||||||
f.someInt64.isNotBetween(BigInt.from(3.0), BigInt.from(5.0)))
|
f.anInt64.isNotBetween(BigInt.from(3.0), BigInt.from(5.0)))
|
||||||
.count(),
|
.count(),
|
||||||
completion(0));
|
completion(0));
|
||||||
});
|
});
|
||||||
|
@ -375,95 +385,97 @@ void main() {
|
||||||
final day1 = DateTime.now().add(Duration(days: 1));
|
final day1 = DateTime.now().add(Duration(days: 1));
|
||||||
final day2 = DateTime.now().add(Duration(days: 2));
|
final day2 = DateTime.now().add(Duration(days: 2));
|
||||||
final day3 = DateTime.now().add(Duration(days: 3));
|
final day3 = DateTime.now().add(Duration(days: 3));
|
||||||
await db.managers.todosTable.create((o) => o(
|
await db.managers.tableWithEveryColumnType.create((o) => o(
|
||||||
content: "Get that math homework done",
|
aText: Value("Get that math homework done"),
|
||||||
status: Value(TodoStatus.open),
|
anIntEnum: Value(TodoStatus.open),
|
||||||
someFloat: Value(5.0),
|
aReal: Value(5.0),
|
||||||
targetDate: Value(day1)));
|
aDateTime: Value(day1)));
|
||||||
await db.managers.todosTable.create((o) => o(
|
await db.managers.tableWithEveryColumnType.create((o) => o(
|
||||||
content: "Get that math homework done",
|
aText: Value("Get that math homework done"),
|
||||||
status: Value(TodoStatus.open),
|
anIntEnum: Value(TodoStatus.open),
|
||||||
targetDate: Value(day2)));
|
aDateTime: Value(day2)));
|
||||||
await db.managers.todosTable.create((o) => o(
|
await db.managers.tableWithEveryColumnType.create((o) => o(
|
||||||
content: "Get that math homework done",
|
aText: Value("Get that math homework done"),
|
||||||
status: Value(TodoStatus.open),
|
anIntEnum: Value(TodoStatus.open),
|
||||||
someFloat: Value(3.0),
|
aReal: Value(3.0),
|
||||||
targetDate: Value(day3)));
|
aDateTime: Value(day3)));
|
||||||
|
|
||||||
// More than
|
// More than
|
||||||
expect(
|
expect(
|
||||||
db.managers.todosTable
|
db.managers.tableWithEveryColumnType
|
||||||
.filter((f) => f.targetDate.isAfter(day2))
|
.filter((f) => f.aDateTime.isAfter(day2))
|
||||||
.count(),
|
.count(),
|
||||||
completion(1));
|
completion(1));
|
||||||
expect(
|
expect(
|
||||||
db.managers.todosTable
|
db.managers.tableWithEveryColumnType
|
||||||
.filter((f) => f.targetDate.isAfterOrOn(day2))
|
.filter((f) => f.aDateTime.isAfterOrOn(day2))
|
||||||
.count(),
|
.count(),
|
||||||
completion(2));
|
completion(2));
|
||||||
|
|
||||||
// Less than
|
// Less than
|
||||||
expect(
|
expect(
|
||||||
db.managers.todosTable
|
db.managers.tableWithEveryColumnType
|
||||||
.filter((f) => f.targetDate.isBefore(day2))
|
.filter((f) => f.aDateTime.isBefore(day2))
|
||||||
.count(),
|
.count(),
|
||||||
completion(1));
|
completion(1));
|
||||||
expect(
|
expect(
|
||||||
db.managers.todosTable
|
db.managers.tableWithEveryColumnType
|
||||||
.filter((f) => f.targetDate.isBeforeOrOn(day2))
|
.filter((f) => f.aDateTime.isBeforeOrOn(day2))
|
||||||
.count(),
|
.count(),
|
||||||
completion(2));
|
completion(2));
|
||||||
|
|
||||||
// Between
|
// Between
|
||||||
expect(
|
expect(
|
||||||
db.managers.todosTable
|
db.managers.tableWithEveryColumnType
|
||||||
.filter((f) => f.targetDate.isBetween(day1, day2))
|
.filter((f) => f.aDateTime.isBetween(day1, day2))
|
||||||
.count(),
|
.count(),
|
||||||
completion(2));
|
completion(2));
|
||||||
expect(
|
expect(
|
||||||
db.managers.todosTable
|
db.managers.tableWithEveryColumnType
|
||||||
.filter((f) => f.targetDate.isNotBetween(day1, day2))
|
.filter((f) => f.aDateTime.isNotBetween(day1, day2))
|
||||||
.count(),
|
.count(),
|
||||||
completion(1));
|
completion(1));
|
||||||
});
|
});
|
||||||
|
|
||||||
test('manager - query custom column', () async {
|
test('manager - query custom column', () async {
|
||||||
await db.managers.todosTable.create((o) => o(
|
await db.managers.tableWithEveryColumnType.create((o) => o(
|
||||||
content: "Get that math homework done",
|
aText: Value("Get that math homework done"),
|
||||||
status: Value(TodoStatus.open)));
|
anIntEnum: Value(TodoStatus.open)));
|
||||||
await db.managers.todosTable.create((o) => o(
|
await db.managers.tableWithEveryColumnType.create((o) => o(
|
||||||
content: "Get that math homework done",
|
aText: Value("Get that math homework done"),
|
||||||
status: Value(TodoStatus.open)));
|
anIntEnum: Value(TodoStatus.open)));
|
||||||
await db.managers.todosTable.create((o) => o(
|
await db.managers.tableWithEveryColumnType.create((o) => o(
|
||||||
content: "Get that math homework done",
|
aText: Value("Get that math homework done"),
|
||||||
status: Value(TodoStatus.workInProgress)));
|
anIntEnum: Value(TodoStatus.workInProgress)));
|
||||||
await db.managers.todosTable.create((o) => o(
|
await db.managers.tableWithEveryColumnType.create((o) => o(
|
||||||
content: "Get that math homework done",
|
aText: Value("Get that math homework done"),
|
||||||
status: Value(TodoStatus.done)));
|
anIntEnum: Value(TodoStatus.done)));
|
||||||
|
|
||||||
// Equals
|
// Equals
|
||||||
expect(
|
expect(
|
||||||
db.managers.todosTable
|
db.managers.tableWithEveryColumnType
|
||||||
.filter((f) => f.status.equals(TodoStatus.open))
|
.filter((f) => f.anIntEnum.equals(TodoStatus.open))
|
||||||
.count(),
|
.count(),
|
||||||
completion(2));
|
completion(2));
|
||||||
expect(
|
expect(
|
||||||
db.managers.todosTable.filter((f) => f.status(TodoStatus.open)).count(),
|
db.managers.tableWithEveryColumnType
|
||||||
|
.filter((f) => f.anIntEnum(TodoStatus.open))
|
||||||
|
.count(),
|
||||||
completion(2));
|
completion(2));
|
||||||
|
|
||||||
// In
|
// In
|
||||||
expect(
|
expect(
|
||||||
db.managers.todosTable
|
db.managers.tableWithEveryColumnType
|
||||||
.filter((f) =>
|
.filter((f) =>
|
||||||
f.status.isIn([TodoStatus.open, TodoStatus.workInProgress]))
|
f.anIntEnum.isIn([TodoStatus.open, TodoStatus.workInProgress]))
|
||||||
.count(),
|
.count(),
|
||||||
completion(3));
|
completion(3));
|
||||||
|
|
||||||
// Not In
|
// Not In
|
||||||
expect(
|
expect(
|
||||||
db.managers.todosTable
|
db.managers.tableWithEveryColumnType
|
||||||
.filter((f) =>
|
.filter((f) => f.anIntEnum
|
||||||
f.status.isNotIn([TodoStatus.open, TodoStatus.workInProgress]))
|
.isNotIn([TodoStatus.open, TodoStatus.workInProgress]))
|
||||||
.count(),
|
.count(),
|
||||||
completion(1));
|
completion(1));
|
||||||
});
|
});
|
||||||
|
|
Loading…
Reference in New Issue