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
{{ message }}
Repository navigation
How to read direction predicates in iterate a cursor? #450
* If key is defined, the record’s key is greater than or equal to key.
* If primaryKey is defined, the record’s key is equal to key and the record’s value is greater than or equal to primaryKey, or the record’s key is greater than key.
* If position is defined, and source is an object store, the record’s key is greater than position.
* If position is defined, and source is an index, the record’s key is equal to position and the record’s value is greater than object store position or the record’s key is greater than position.
* The record’s key is in range.
How are some of these conditions supposed to be read?
eg. the second one, is it like this? (same issue with the 4th one)
If primaryKey is defined:
the record’s key is equal to key and the record’s value is greater than or equal to primaryKey,
else:
the record’s key is greater than key.
or like this?
If primaryKey is defined:
(the record’s key is equal to key and the record’s value is greater than or equal to primaryKey) OR the record’s key is greater than key.
If primaryKey is defined, the record’s [index] key is equal to [index] key and the record’s value [primaryKey] is greater than or equal to primaryKey.
If primaryKey is defined, the record’s [index] key is greater than [index] key.
Each of the bullets is a predicate that restricts the range of potential keys. Another way of saying this would be: "If there's a matching key/primaryKey, then that's the result. Otherwise it's the next in order with a matching key. If there isn't one of those it's the next in order." But it's not that simple, since if the cursor has advanced past that position then nothing should be found. Hence the current formulation.
Probably also worth noting: "next" is the easy case, where iterating is in natural order (that is, sorted first by the index key, the secondarily by the primary key. "nextunique" and "prev" are similarly unsurprising. "prevunique" is more complicated, because we agreed to match SQLite semantics and return the first plausible record rather than the last plausible record.
Activity
inexorabletash commentedon Apr 29, 2025
The latter. It might be clearer to format as:
... and similarly for the other predicates with "or" in them.
SteveBeckerMSFT commentedon May 1, 2025
For the clearer format suggested by @inexorabletash, how is OR implied between the sub-bullets?
inexorabletash commentedon May 1, 2025
It's an "AND", so to be fully explicit:
Each of the bullets is a predicate that restricts the range of potential keys. Another way of saying this would be: "If there's a matching key/primaryKey, then that's the result. Otherwise it's the next in order with a matching key. If there isn't one of those it's the next in order." But it's not that simple, since if the cursor has advanced past that position then nothing should be found. Hence the current formulation.
inexorabletash commentedon May 2, 2025
Probably also worth noting:
"next"is the easy case, where iterating is in natural order (that is, sorted first by the index key, the secondarily by the primary key."nextunique"and"prev"are similarly unsurprising."prevunique"is more complicated, because we agreed to match SQLite semantics and return the first plausible record rather than the last plausible record.