Commit ff648ad
authored
Declarative field defaults (incl. the current_user token) were resolved
after the beforeInsert hook, so a hook deriving one field from another
read a stale null for any field about to be defaulted. Move
applyFieldDefaults to record-initialization time, before beforeInsert —
matching the standard order of execution (declarative defaults before
before-triggers; autonumber/encryption/validation stay after). The hook
still runs after and may override defaults; caller input is no longer
mutated in place.
Adds a regression test reproducing the os-tianshun-mtc#29 scenario.
1 parent bea4b92 commit ff648ad
3 files changed
Lines changed: 77 additions & 12 deletions
File tree
- .changeset
- packages/objectql/src
| 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 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
319 | 319 | | |
320 | 320 | | |
321 | 321 | | |
| 322 | + | |
| 323 | + | |
| 324 | + | |
| 325 | + | |
| 326 | + | |
| 327 | + | |
| 328 | + | |
| 329 | + | |
| 330 | + | |
| 331 | + | |
| 332 | + | |
| 333 | + | |
| 334 | + | |
| 335 | + | |
| 336 | + | |
| 337 | + | |
| 338 | + | |
| 339 | + | |
| 340 | + | |
| 341 | + | |
| 342 | + | |
| 343 | + | |
| 344 | + | |
| 345 | + | |
| 346 | + | |
| 347 | + | |
| 348 | + | |
| 349 | + | |
| 350 | + | |
| 351 | + | |
322 | 352 | | |
323 | 353 | | |
324 | 354 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
2131 | 2131 | | |
2132 | 2132 | | |
2133 | 2133 | | |
| 2134 | + | |
| 2135 | + | |
| 2136 | + | |
| 2137 | + | |
| 2138 | + | |
| 2139 | + | |
| 2140 | + | |
| 2141 | + | |
| 2142 | + | |
| 2143 | + | |
| 2144 | + | |
| 2145 | + | |
| 2146 | + | |
2134 | 2147 | | |
2135 | 2148 | | |
2136 | 2149 | | |
2137 | | - | |
| 2150 | + | |
2138 | 2151 | | |
2139 | 2152 | | |
2140 | 2153 | | |
| |||
2150 | 2163 | | |
2151 | 2164 | | |
2152 | 2165 | | |
2153 | | - | |
2154 | 2166 | | |
2155 | 2167 | | |
2156 | 2168 | | |
2157 | 2169 | | |
2158 | 2170 | | |
2159 | | - | |
2160 | | - | |
2161 | | - | |
2162 | | - | |
| 2171 | + | |
| 2172 | + | |
| 2173 | + | |
2163 | 2174 | | |
2164 | 2175 | | |
2165 | 2176 | | |
| |||
2178 | 2189 | | |
2179 | 2190 | | |
2180 | 2191 | | |
2181 | | - | |
2182 | | - | |
2183 | | - | |
2184 | | - | |
2185 | | - | |
2186 | | - | |
| 2192 | + | |
| 2193 | + | |
2187 | 2194 | | |
2188 | 2195 | | |
2189 | 2196 | | |
| |||
0 commit comments