Commit 9efb8a0
authored
fix: stabilize field order in Ash.Expr.determine_map_type/1 (#2679)
Iterating a literal map expr (e.g. `expr(%{a: id, b: name})`) produces
a `{Ash.Type.Map, fields: [...]}` whose field order depends on Erlang
map iteration, which for small flatmaps is driven by internal atom
term ordering and varies between BEAM loads. Downstream consumers
that render ordered output (e.g. ash_typescript codegen) see flaky,
shuffled results across compiles.
Sort the resulting fields by atom name before returning so the output
is stable across compiles. The contract is only "deterministic", not
"alphabetical forever" — consumers should not rely on the specific
order, only that it doesn't change.1 parent 83c62b1 commit 9efb8a0
2 files changed
Lines changed: 18 additions & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1728 | 1728 | | |
1729 | 1729 | | |
1730 | 1730 | | |
1731 | | - | |
| 1731 | + | |
| 1732 | + | |
| 1733 | + | |
| 1734 | + | |
1732 | 1735 | | |
1733 | 1736 | | |
1734 | 1737 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
212 | 212 | | |
213 | 213 | | |
214 | 214 | | |
| 215 | + | |
| 216 | + | |
| 217 | + | |
| 218 | + | |
215 | 219 | | |
216 | 220 | | |
217 | 221 | | |
| |||
371 | 375 | | |
372 | 376 | | |
373 | 377 | | |
| 378 | + | |
| 379 | + | |
| 380 | + | |
| 381 | + | |
| 382 | + | |
| 383 | + | |
| 384 | + | |
| 385 | + | |
| 386 | + | |
| 387 | + | |
374 | 388 | | |
375 | 389 | | |
376 | 390 | | |
| |||
0 commit comments