Commit ec975f1
authored
findOne reads a single row, which makes its predicate the only thing between
the caller and an arbitrary record. When the predicate is missing the result is
not `null` — it is the object's FIRST ROW: a real, plausible-looking record
with nothing to do with the request, which the `if (!row)` check every call
site already has cannot catch, and which then propagates into whatever is
computed next.
#4419 reported this against the `filter` key, which #4346 (fold on every entry
point) and #4400 (unknown keys throw) already closed. This is what those left
standing.
BREAKING: findOne refuses a query that selects nothing in particular.
findOne(o) / findOne(o, {}) / findOne(o, { where: {} })
-> findOne(o, { where: … }) the record matching this
-> findOne(o, { search: 'Acme' }) the record this search finds
-> findOne(o, { orderBy: [{ field, order }] }) the FIRST in this order
-> find(o, { limit: 1 }) any row will do, said aloud
The error names all four. `find` and `count` are unchanged — returning or
counting every row is an honest answer. The guard reads the CALLER's predicate,
before RLS/sharing middleware injects its own.
Two silent drops that produced the same wrong record are fixed with it:
- findOne({ search }) now applies the search. The ADR-0061 expansion lived in
find() alone while both methods are checked against the SAME legal-key set,
so `search` passed the gate, reached a driver that does not read it, and the
read ran unpredicated.
- MongoDBDriver.findOne now applies orderBy, fields and offset. It translated
`where` and dropped the rest, so "the newest record" returned whichever
document the scan reached first. No ordering is imposed when the caller
supplies none (#4363) — unchanged on both drivers.
And a drift pin walks ENGINE_OPTION_KEY_SETS.findOne requiring each declared
key to have an observable effect, so the next declared-but-unexecuted key fails
CI instead of shipping. The Mongo cases live in one shared table read by both a
server-free options suite and the real-mongod suite, so neither half can drift.
1 parent e6b1b69 commit ec975f1
13 files changed
Lines changed: 1131 additions & 48 deletions
File tree
- .changeset
- content/docs
- kernel/contracts
- releases
- packages
- objectql/src
- plugins
- driver-mongodb/src
- driver-sql/src
- spec/src/contracts
- skills/objectstack-data/references
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
146 | 146 | | |
147 | 147 | | |
148 | 148 | | |
149 | | - | |
| 149 | + | |
150 | 150 | | |
151 | 151 | | |
152 | 152 | | |
| |||
155 | 155 | | |
156 | 156 | | |
157 | 157 | | |
| 158 | + | |
| 159 | + | |
| 160 | + | |
| 161 | + | |
| 162 | + | |
| 163 | + | |
| 164 | + | |
| 165 | + | |
| 166 | + | |
| 167 | + | |
| 168 | + | |
| 169 | + | |
| 170 | + | |
| 171 | + | |
| 172 | + | |
| 173 | + | |
| 174 | + | |
| 175 | + | |
158 | 176 | | |
159 | 177 | | |
160 | 178 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
930 | 930 | | |
931 | 931 | | |
932 | 932 | | |
| 933 | + | |
| 934 | + | |
| 935 | + | |
| 936 | + | |
| 937 | + | |
| 938 | + | |
| 939 | + | |
| 940 | + | |
| 941 | + | |
| 942 | + | |
| 943 | + | |
| 944 | + | |
| 945 | + | |
| 946 | + | |
| 947 | + | |
| 948 | + | |
| 949 | + | |
| 950 | + | |
| 951 | + | |
| 952 | + | |
| 953 | + | |
| 954 | + | |
| 955 | + | |
| 956 | + | |
| 957 | + | |
| 958 | + | |
| 959 | + | |
| 960 | + | |
| 961 | + | |
| 962 | + | |
| 963 | + | |
| 964 | + | |
| 965 | + | |
| 966 | + | |
| 967 | + | |
| 968 | + | |
| 969 | + | |
| 970 | + | |
| 971 | + | |
| 972 | + | |
| 973 | + | |
| 974 | + | |
| 975 | + | |
| 976 | + | |
933 | 977 | | |
934 | 978 | | |
935 | 979 | | |
| |||
0 commit comments