Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Invalid predicate error on try to sort by field with name "sort". #7545

Closed
TemMax opened this issue Aug 12, 2021 · 4 comments · Fixed by realm/realm-core#4905
Closed

Invalid predicate error on try to sort by field with name "sort". #7545

TemMax opened this issue Aug 12, 2021 · 4 comments · Fixed by realm/realm-core#4905
Assignees

Comments

@TemMax
Copy link

TemMax commented Aug 12, 2021

Goal

Want to receive a sorted list from db.

Actual Results

App is crashed with this log:
Caused by: java.lang.IllegalArgumentException: Illegal Argument: Invalid predicate: 'TRUEPREDICATE SORT(sort ASC)': syntax error, unexpected sort in /tmp/realm-java/realm/realm-library/src/main/cpp/io_realm_internal_TableQuery.cpp line 527

Steps & Code to Reproduce

For reproduce you can try to create a class that extents RealmObject, add field (var sort: Int = 0). Then try to fetch this objects with query with .sort() function call.

Version of Realm and tooling

Realm version(s): 10.7.1

Realm Sync feature enabled: No

Android Studio version: 2020.3.1

Android Build Tools version: 30.0.3

Gradle version: 7.0.2

Which Android version and device(s): 11

@bmunkholm
Copy link
Contributor

@ironage is "sort" considered a reserved keyword that users can't use a field?

@bmunkholm
Copy link
Contributor

@TemMax For now I think you should consider "sort" a field name we don't support. I'm not sure if we will in the future. I'll see what @ironage has to say about that.

@TemMax
Copy link
Author

TemMax commented Sep 14, 2021

Sure. I already wrote migration for my DB. But it's strange that "sort" field name was supported in old versions (4-6) and not supported in current versions :)
I faced with this bug due migration my old app with very old version of Realm on the last one.

@bmunkholm
Copy link
Contributor

Yeah it seems like an oversight when we replaced our query engine. I honestly can't recall if we mentioned that in the release notes and was too lazy to check it ;-).

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Mar 15, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants