Skip to main content

Timeline for how does SOQL compare IDs

Current License: CC BY-SA 4.0

15 events
when toggle format what by license comment
Jul 5, 2019 at 9:17 answer added Yiyun Liu timeline score: 2
Jul 5, 2019 at 8:27 comment added tiruman To be on the save side, I'd just filter for (ParentId < ‘a1f000000000000000’).
Jul 5, 2019 at 6:41 comment added user2957592 @PhilW Yeah i realized that. I just edited title of the post (removed "apex" from it) and added the edit at the end
Jul 5, 2019 at 6:40 history edited user2957592 CC BY-SA 4.0
added 321 characters in body; edited tags; edited title
Jul 5, 2019 at 6:39 comment added Phil W OK, not obvious from your question but fair enough. Just because you were running with workbench didn't imply the final solution is workbench :)
Jul 5, 2019 at 6:37 comment added user2957592 @PhilW I need to run queries via workbench, so i dont have the option to use object describe
Jul 5, 2019 at 6:35 comment added Phil W That's in the context of SOQL so may include some implicit conversion. Who knows?
Jul 5, 2019 at 6:34 comment added user2957592 @kur I guess the real question is when i write where (ParentId > ‘a1e000000000000000’) AND (ParentId <‘a1ezzzzzzzzzzzzzzz’) how is that comparison done? I guess this is ID being compared to string. But whats the internal mechanism? I just want to make sure ID of ALL the records fall in that range
Jul 5, 2019 at 6:34 comment added Phil W @Eric, I'd say order of ID is irrelevant here since the query is trying to cover the entire ID range with a given prefix. Something else worth considering - don't hard-code the ID prefix, get this from the object describe (DescribeSObjectResult.keyPrefix). And talking about that, note the following caveat in the docs: "Note that a key prefix can sometimes be shared by multiple objects so it does not always uniquely identify an object".
Jul 5, 2019 at 6:29 comment added Phil W You've used the 18 character ID form which exists to make the ID case insensitive. What happens if you do this with the 15 character form? (And make sure you do compare ID to ID, not ID to String as @kurunve mentioned)
Jul 5, 2019 at 6:06 comment added kurunve did you try to compare Id with Id (because now it seems they Id with String is compared)?
Jul 5, 2019 at 5:59 comment added Eric I guess I should say sequentially rather than chronological. Depending on you rage the may not matter
Jul 5, 2019 at 5:55 comment added zaitsman @Eric then again, they do recommend to use id forward paging in LDS docos..
Jul 5, 2019 at 5:42 comment added Eric While ids are unique they are not guaranteed to be in chronological order. Just something to keep in mine.
Jul 5, 2019 at 5:36 history asked user2957592 CC BY-SA 4.0