You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I am storing chat messages in a table and wanted to extract the last message inserted. Doing it via timestamp might be inaccurate as theoretically there could be multiple messages generated in a millisecond. Only way out is to use my own auto increment column which I want to avoid.
Also I wanted to sort the messages in the reverse insertion order.
Yes, IDs "happen" to work for that local case. Technically, we don't give guarantees that this will stay like this forever, and, e.g. if you'd use Sync, it would break right away.
Other than that, we'll look into the compilation issue, of course. It will take some time though, as there are other things on our priority queue.
This is because ordered(by) and setParameter() do not support Id properties (they are restricted to Property<ObjectBox.QueryBuilder<E>.EntityType, T, Void>, but for Id properties the last type parameter is not Void).
The methods would have to be changed to explicitly allow using Id properties. So changing this into an enhancement suggestion.
Activity
greenrobot commentedon Jun 7, 2021
Some people say IDs should not used in queries at all as they should not represent any application data. What's your use case?
singlakarun commentedon Jun 7, 2021
I am storing chat messages in a table and wanted to extract the last message inserted. Doing it via timestamp might be inaccurate as theoretically there could be multiple messages generated in a millisecond. Only way out is to use my own auto increment column which I want to avoid.
Also I wanted to sort the messages in the reverse insertion order.
greenrobot commentedon Jun 7, 2021
Yes, IDs "happen" to work for that local case. Technically, we don't give guarantees that this will stay like this forever, and, e.g. if you'd use Sync, it would break right away.
Other than that, we'll look into the compilation issue, of course. It will take some time though, as there are other things on our priority queue.
greenrobot-team commentedon Aug 7, 2024
This is because
ordered(by)
andsetParameter()
do not supportId
properties (they are restricted toProperty<ObjectBox.QueryBuilder<E>.EntityType, T, Void>
, but forId
properties the last type parameter is notVoid
).The methods would have to be changed to explicitly allow using
Id
properties. So changing this into an enhancement suggestion.