Commit abcdaed
committed
Feat: Allow Pre-save hooks on the create operations
1- Add beforeCreate hook to CreateMany and CreateManyAndReturn wrappers to allow mutation on the struct before it's serialized to SQL rows
2- Add ToRowMap() on {Model}Create as the single exit point from the struct
representation, with per field nil checks, default injection, and CUID/UUID generation (if present)
3- establish a flow of create api takes the FieldAssignment spread and generates a struct via assignmentsTo{Model}Create, and the pre-save hook mutates that struct if preset, then, the base struct is converted to to a map via ToRowMap() that's used to generate the SQL rows in create operations
4- Remove RecordsToRowMaps generator function because ToRowMap() now owns the
struct to map conversion with proper defaults, eliminating the duplicated
default/CUID logic between RecordsToRowMaps and the single-create path
5- Remove Assignments() on {Model}Create because ToRowMap() replaces it as the single back-conversion path structs no longer round-trip through Field assignment
6- Remove validateFn, rowMapFn, and singleCreateFn params from executeCreateMany/AndReturn
since validation is handled at FieldAssignment level in the wrapper and map conversion is inline via ToRowMap(), the fallback per-row path uses mapToColsVals + executeInsert instead of re-entering singleCreateFn (which would double-fire hooks, and it did)1 parent ce22dd6 commit abcdaed
12 files changed
Lines changed: 496 additions & 331 deletions
File tree
- generator
- templates
- integration
- valk
This file was deleted.
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
178 | 178 | | |
179 | 179 | | |
180 | 180 | | |
181 | | - | |
| 181 | + | |
182 | 182 | | |
183 | 183 | | |
184 | | - | |
| 184 | + | |
185 | 185 | | |
186 | 186 | | |
187 | | - | |
188 | | - | |
189 | | - | |
190 | 187 | | |
191 | | - | |
| 188 | + | |
192 | 189 | | |
193 | 190 | | |
194 | | - | |
195 | | - | |
196 | | - | |
197 | | - | |
198 | | - | |
199 | 191 | | |
200 | 192 | | |
201 | | - | |
202 | 193 | | |
203 | 194 | | |
204 | 195 | | |
| |||
209 | 200 | | |
210 | 201 | | |
211 | 202 | | |
212 | | - | |
213 | | - | |
| 203 | + | |
| 204 | + | |
| 205 | + | |
214 | 206 | | |
215 | 207 | | |
216 | 208 | | |
| |||
224 | 216 | | |
225 | 217 | | |
226 | 218 | | |
227 | | - | |
| 219 | + | |
228 | 220 | | |
229 | 221 | | |
230 | 222 | | |
231 | 223 | | |
232 | | - | |
233 | | - | |
234 | 224 | | |
235 | 225 | | |
236 | 226 | | |
237 | | - | |
238 | 227 | | |
| 228 | + | |
239 | 229 | | |
240 | | - | |
| 230 | + | |
241 | 231 | | |
242 | 232 | | |
243 | | - | |
244 | | - | |
245 | | - | |
246 | | - | |
247 | | - | |
248 | 233 | | |
249 | 234 | | |
250 | 235 | | |
251 | 236 | | |
252 | 237 | | |
253 | | - | |
254 | 238 | | |
255 | 239 | | |
256 | 240 | | |
| |||
282 | 266 | | |
283 | 267 | | |
284 | 268 | | |
285 | | - | |
286 | | - | |
| 269 | + | |
| 270 | + | |
| 271 | + | |
287 | 272 | | |
288 | 273 | | |
289 | 274 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
148 | 148 | | |
149 | 149 | | |
150 | 150 | | |
| 151 | + | |
| 152 | + | |
| 153 | + | |
| 154 | + | |
| 155 | + | |
| 156 | + | |
| 157 | + | |
| 158 | + | |
| 159 | + | |
| 160 | + | |
| 161 | + | |
| 162 | + | |
| 163 | + | |
| 164 | + | |
| 165 | + | |
| 166 | + | |
| 167 | + | |
| 168 | + | |
| 169 | + | |
| 170 | + | |
| 171 | + | |
| 172 | + | |
| 173 | + | |
| 174 | + | |
| 175 | + | |
| 176 | + | |
| 177 | + | |
| 178 | + | |
| 179 | + | |
| 180 | + | |
| 181 | + | |
| 182 | + | |
| 183 | + | |
| 184 | + | |
| 185 | + | |
| 186 | + | |
| 187 | + | |
| 188 | + | |
| 189 | + | |
| 190 | + | |
| 191 | + | |
| 192 | + | |
| 193 | + | |
| 194 | + | |
| 195 | + | |
| 196 | + | |
| 197 | + | |
| 198 | + | |
| 199 | + | |
| 200 | + | |
| 201 | + | |
| 202 | + | |
| 203 | + | |
| 204 | + | |
| 205 | + | |
| 206 | + | |
| 207 | + | |
| 208 | + | |
151 | 209 | | |
152 | 210 | | |
153 | 211 | | |
| |||
266 | 324 | | |
267 | 325 | | |
268 | 326 | | |
269 | | - | |
270 | | - | |
271 | | - | |
272 | | - | |
273 | | - | |
274 | | - | |
275 | | - | |
276 | | - | |
277 | | - | |
278 | | - | |
279 | | - | |
280 | | - | |
281 | | - | |
282 | | - | |
283 | | - | |
284 | | - | |
285 | | - | |
286 | | - | |
287 | | - | |
288 | | - | |
289 | | - | |
290 | | - | |
291 | | - | |
292 | | - | |
293 | | - | |
294 | | - | |
295 | | - | |
296 | | - | |
297 | | - | |
298 | | - | |
299 | 327 | | |
300 | 328 | | |
301 | 329 | | |
| |||
313 | 341 | | |
314 | 342 | | |
315 | 343 | | |
316 | | - | |
317 | | - | |
318 | | - | |
319 | | - | |
320 | | - | |
321 | | - | |
322 | | - | |
| 344 | + | |
| 345 | + | |
| 346 | + | |
| 347 | + | |
| 348 | + | |
| 349 | + | |
| 350 | + | |
| 351 | + | |
| 352 | + | |
| 353 | + | |
| 354 | + | |
| 355 | + | |
| 356 | + | |
| 357 | + | |
323 | 358 | | |
324 | 359 | | |
325 | 360 | | |
326 | | - | |
327 | | - | |
328 | | - | |
| 361 | + | |
| 362 | + | |
| 363 | + | |
| 364 | + | |
| 365 | + | |
| 366 | + | |
| 367 | + | |
| 368 | + | |
| 369 | + | |
| 370 | + | |
| 371 | + | |
| 372 | + | |
| 373 | + | |
| 374 | + | |
| 375 | + | |
329 | 376 | | |
330 | 377 | | |
331 | 378 | | |
332 | | - | |
333 | | - | |
334 | | - | |
335 | 379 | | |
| 380 | + | |
336 | 381 | | |
337 | 382 | | |
0 commit comments