Commit ba7e237
committed
fix(objectql): assign autonumbers after validation; document at-least-once hooks (#3152)
In the batch insert path, beforeInsert hooks and autonumber assignment
ran before per-row validation. When bulkWrite degrades a batch to per-row
(or retries it), the whole engine.insert re-runs, so a batch that dies in
validation had already consumed an autonumber sequence value for every
good row — leaving number-range gaps — and re-fired side-effecting
beforeInsert hooks on the retry.
Move autonumber assignment to after validation: a doomed attempt now
consumes no sequence value (required-validation already exempts
autonumber fields, and a driver-owned autonumber assigns nothing here, so
no validation rule can depend on the value — the reorder is safe). The
remaining beforeInsert double-execution on a degraded batch is documented
as at-least-once hook semantics on engine.insert (hooks must be
idempotent); root-causing it needs a partial-success engine API, out of
scope here.
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01APnSDJneEDRh3Z51KGCLga1 parent 45c5df6 commit ba7e237
2 files changed
Lines changed: 115 additions & 3 deletions
| 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 | + | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
| 78 | + | |
| 79 | + | |
| 80 | + | |
| 81 | + | |
| 82 | + | |
| 83 | + | |
| 84 | + | |
| 85 | + | |
| 86 | + | |
| 87 | + | |
| 88 | + | |
| 89 | + | |
| 90 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
2200 | 2200 | | |
2201 | 2201 | | |
2202 | 2202 | | |
| 2203 | + | |
| 2204 | + | |
| 2205 | + | |
| 2206 | + | |
| 2207 | + | |
| 2208 | + | |
| 2209 | + | |
| 2210 | + | |
| 2211 | + | |
| 2212 | + | |
| 2213 | + | |
| 2214 | + | |
| 2215 | + | |
| 2216 | + | |
2203 | 2217 | | |
2204 | 2218 | | |
2205 | 2219 | | |
| |||
2271 | 2285 | | |
2272 | 2286 | | |
2273 | 2287 | | |
2274 | | - | |
2275 | | - | |
2276 | | - | |
2277 | 2288 | | |
2278 | 2289 | | |
2279 | 2290 | | |
| |||
2282 | 2293 | | |
2283 | 2294 | | |
2284 | 2295 | | |
| 2296 | + | |
| 2297 | + | |
| 2298 | + | |
| 2299 | + | |
| 2300 | + | |
| 2301 | + | |
| 2302 | + | |
| 2303 | + | |
| 2304 | + | |
| 2305 | + | |
| 2306 | + | |
2285 | 2307 | | |
2286 | 2308 | | |
2287 | 2309 | | |
| |||
0 commit comments