-
Type: Bug
-
Resolution: Fixed
-
Priority: Major - P3
-
None
-
Affects Version/s: None
-
Component/s: None
-
?
-
7935
-
Not Needed
What happened?
I got Unhandled Exception: RealmException: Invalid column key. Error code: 3009. when trying to use the between key for a DateTime field.
Repro steps
Using a child property with the BETWEEN keyword doesn't work. Using < or > operators works with child properties without issue.
The exception is thrown regardless of whether the query should return anything.
Version
3.19
What Atlas Services are you using?
Local Database only
What type of application is this?
Flutter Application
Client OS and version
Android & Linux
Code snippets
This is sufficient code to expose the issue.
Unable to find source-code formatter for language: main. Available languages are: actionscript, ada, applescript, bash, c, c#, c++, cpp, css, erlang, go, groovy, haskell, html, java, javascript, js, json, lua, none, nyan, objc, perl, php, python, r, rainbow, ruby, scala, sh, sql, swift, visualbasic, xml, yaml
import 'package:realm/realm.dart'; import "model.dart"; void main() { final config = Configuration.inMemory([Parent.schema, Child.schema]); final realm = Realm(config); final stop = DateTime.now(); final start = stop.subtract(const Duration(days: 1)); print("The naive way:"); realm.query<Parent>(r"$0 <= child.timestamp && child.timestamp <= $1", [start, stop]); print("The between way:"); realm.query<Parent>(r"child.timestamp between {$0, $1}", [start, stop]); }
Unable to find source-code formatter for language: model. Available languages are: actionscript, ada, applescript, bash, c, c#, c++, cpp, css, erlang, go, groovy, haskell, html, java, javascript, js, json, lua, none, nyan, objc, perl, php, python, r, rainbow, ruby, scala, sh, sql, swift, visualbasic, xml, yaml
import 'package:realm/realm.dart'; part "model.realm.dart"; @RealmModel() class $Child { late DateTime timestamp; } @RealmModel() class $Parent { $Child? child; }
Stacktrace of the exception/crash you're getting
Unable to find source-code formatter for language: shell. Available languages are: actionscript, ada, applescript, bash, c, c#, c++, cpp, css, erlang, go, groovy, haskell, html, java, javascript, js, json, lua, none, nyan, objc, perl, php, python, r, rainbow, ruby, scala, sh, sql, swift, visualbasic, xml, yaml
[ERROR:flutter/runtime/dart_vm_initializer.cc(41)] Unhandled Exception: RealmException: Invalid column key. Error code: 3009. #0 _raiseLastError.<anonymous closure> (package:realm_dart/src/handles/native/error_handling.dart:59:9) realm/realm-dart#1 using (package:ffi/src/arena.dart:124:31) realm/realm-dart#2 _raiseLastError (package:realm_dart/src/handles/native/error_handling.dart:48:3) realm/realm-dart#3 BoolEx.raiseLastErrorIfFalse (package:realm_dart/src/handles/native/error_handling.dart:25:7) realm/realm-dart#4 ResultsHandle.count.<anonymous closure> (package:realm_dart/src/handles/native/results_handle.dart:74:55) realm/realm-dart#5 using (package:ffi/src/arena.dart:124:31) realm/realm-dart#6 ResultsHandle.count (package:realm_dart/src/handles/native/results_handle.dart:72:12) realm/realm-dart#7 RealmResults.length (package:realm_dart/src/results.dart:115:28) realm/realm-dart#8 new RealmResults._ (package:realm_dart/src/results.dart:30:12) realm/realm-dart#9 RealmResultsInternal.create (package:realm_dart/src/results.dart:298:7) realm/realm-dart#10 Realm.query (package:realm_dart/src/realm_class.dart:435:33) realm/realm-dart#11 main (package:realm_test/main.dart:14:9) realm/realm-dart#12 _runMain.<anonymous closure> (dart:ui/hooks.dart:301:23) realm/realm-dart#13 _delayEntrypointInvocation.<anonymous closure> (dart:isolate-patch/isolate_patch.dart:297:19) realm/realm-dart#14 _RawReceivePort._handleMessage (dart:isolate-patch/isolate_patch.dart:184:12)
Relevant log output
No response