Commit f722475
committed
surreal: normalize nulls/dates/ids, refactor schema & autoincrement, and update tests
- Add helpers to detect Surreal record IDs and ISO-like datetimes; avoid quoting record IDs and emit datetime literals consistently.
- Use NONE as SurrealDB null representation (VALUE/ASSERT/WHERE emit NONE), and adjust query generator (IS NONE).
- Rename migration/history table to `_allographer_migrations`, add createMigrationTable(isReset) to allow reset/removal, and store created_at in ISO8601 'T...Z' format.
- Rework autoincrement flow: centralize _autoincrement_sequences usage, compute next-index expression, update event/field definitions to use the sequence, and change migration primary column from `id` to `index`.
- Append "RETURN AFTER" to INSERT builders and simplify insertId paths to reliably obtain returned IDs.
- Refactor create_column_query: introduce helpers (addAssertPart/addValueClause/addAssertClause/autoIncrementValueExpr) to centralize value/default/assert logic and improve nullable/default handling across types (string, int, decimal, datetime, json, record).
- Fix/adjust query behaviors (use math::mean for avg), improve avg parsing for multiple JSON numeric kinds, and tighten JSON/record field syntax.
- Add test utilities and env defaults (envIntDefault/envStringDefault, isNullish, normalizeInfoDef) and update tests to match new behavior (table/index renames, null checks, function name changes, datetime formats).
- Miscellaneous SurrealDB compatibility and normalization fixes across impl, exec, schema utils, and tests.1 parent e5b9629 commit f722475
17 files changed
Lines changed: 561 additions & 366 deletions
File tree
- src/allographer
- query_builder
- libs/surreal
- models/surreal
- query
- schema_builder
- queries/surreal
- sub
- usecases
- sub
- surreal
- tests
- surrealdb
Lines changed: 62 additions & 2 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
2 | 2 | | |
3 | 3 | | |
4 | 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 | + | |
5 | 57 | | |
6 | 58 | | |
7 | 59 | | |
8 | 60 | | |
| 61 | + | |
| 62 | + | |
9 | 63 | | |
10 | 64 | | |
11 | 65 | | |
| |||
93 | 147 | | |
94 | 148 | | |
95 | 149 | | |
96 | | - | |
| 150 | + | |
| 151 | + | |
| 152 | + | |
| 153 | + | |
| 154 | + | |
| 155 | + | |
| 156 | + | |
97 | 157 | | |
98 | 158 | | |
99 | 159 | | |
100 | 160 | | |
101 | 161 | | |
102 | 162 | | |
103 | | - | |
| 163 | + | |
104 | 164 | | |
105 | 165 | | |
106 | 166 | | |
| |||
Lines changed: 3 additions & 3 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
214 | 214 | | |
215 | 215 | | |
216 | 216 | | |
217 | | - | |
| 217 | + | |
218 | 218 | | |
219 | | - | |
| 219 | + | |
220 | 220 | | |
221 | 221 | | |
222 | 222 | | |
| |||
375 | 375 | | |
376 | 376 | | |
377 | 377 | | |
378 | | - | |
| 378 | + | |
379 | 379 | | |
380 | 380 | | |
381 | 381 | | |
| |||
Lines changed: 16 additions & 13 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
391 | 391 | | |
392 | 392 | | |
393 | 393 | | |
394 | | - | |
| 394 | + | |
395 | 395 | | |
396 | 396 | | |
397 | | - | |
398 | | - | |
399 | | - | |
400 | | - | |
| 397 | + | |
401 | 398 | | |
402 | 399 | | |
403 | 400 | | |
404 | 401 | | |
405 | | - | |
| 402 | + | |
406 | 403 | | |
407 | 404 | | |
408 | 405 | | |
| |||
431 | 428 | | |
432 | 429 | | |
433 | 430 | | |
434 | | - | |
| 431 | + | |
435 | 432 | | |
436 | 433 | | |
437 | | - | |
438 | | - | |
439 | | - | |
440 | | - | |
| 434 | + | |
441 | 435 | | |
442 | 436 | | |
443 | 437 | | |
444 | 438 | | |
445 | 439 | | |
446 | 440 | | |
447 | 441 | | |
448 | | - | |
| 442 | + | |
449 | 443 | | |
450 | 444 | | |
451 | 445 | | |
| |||
573 | 567 | | |
574 | 568 | | |
575 | 569 | | |
576 | | - | |
| 570 | + | |
| 571 | + | |
| 572 | + | |
| 573 | + | |
| 574 | + | |
| 575 | + | |
| 576 | + | |
| 577 | + | |
| 578 | + | |
| 579 | + | |
577 | 580 | | |
578 | 581 | | |
579 | 582 | | |
| |||
Lines changed: 7 additions & 2 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
13 | 13 | | |
14 | 14 | | |
15 | 15 | | |
16 | | - | |
| 16 | + | |
17 | 17 | | |
18 | 18 | | |
19 | 19 | | |
| |||
23 | 23 | | |
24 | 24 | | |
25 | 25 | | |
26 | | - | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
27 | 32 | | |
28 | 33 | | |
29 | 34 | | |
| |||
Lines changed: 2 additions & 2 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
75 | 75 | | |
76 | 76 | | |
77 | 77 | | |
78 | | - | |
| 78 | + | |
79 | 79 | | |
80 | 80 | | |
81 | 81 | | |
| |||
107 | 107 | | |
108 | 108 | | |
109 | 109 | | |
110 | | - | |
| 110 | + | |
111 | 111 | | |
112 | 112 | | |
113 | 113 | | |
| |||
0 commit comments