Closed ebadta81 closed 1 year ago
Run the test code.
TestClass_.time.greaterThan(time) should not include "2020-01-01" TestClass entry in the result set.
TestClass_.time.greaterThan(time)
import 'package:datetime_test/objectbox.g.dart'; import 'package:flutter/material.dart'; import 'package:path_provider/path_provider.dart'; @Entity() class TestClass { @Id() int id; DateTime time; TestClass(this.id, this.time); } void main() async { WidgetsFlutterBinding.ensureInitialized(); final dir = await getApplicationSupportDirectory(); String obDirPath = '${dir.path}/objectbox'; Store MBStore = Store(getObjectBoxModel(), directory: obDirPath, queriesCaseSensitiveDefault: false); final tbox = MBStore.box<TestClass>(); tbox.put(TestClass(0, DateTime.parse("2020-01-01"))); tbox.put(TestClass(0, DateTime.parse("2023-04-20"))); final time = DateTime.now().subtract(const Duration(days: 90)).millisecondsSinceEpoch; var q1 = TestClass_.id.greaterThan(0); q1.and(TestClass_.time.greaterThan(time)); final list = tbox.query(q1).build().find(); for (final item in list) { print("id: ${item.id} time: ${item.time}"); } runApp(const MyApp()); }
flutter: id: 1 time: 2020-01-01 00:00:00.000 flutter: id: 2 time: 2023-04-20 00:00:00.000
My bad. Forgot to give the additional condition to q1.
Basic info:
Steps to reproduce
Run the test code.
Expected behavior
TestClass_.time.greaterThan(time)
should not include "2020-01-01" TestClass entry in the result set.Code
Logs, stack traces