Sorts an array of items by Sequence, then alphabetically by a type-appropriate name field,
and finally by ID as a last-resort tiebreaker. This ensures that generated code maintains
the same order across multiple CodeGen runs and across different database environments,
even when Sequence values are identical (e.g., all 0 or all 1).
Why no __mj_CreatedAt tiebreaker: timestamps are set with GETUTCDATE() at insert time
and diverge per environment (the dev who originally generated metadata gets one set of
timestamps; a clean install via Flyway gets another, batched into the same SQL Server tick).
Using them as a sort key made codegen output a function of DB-resident insertion history
rather than of metadata identity, which is the root cause of the long-running "flip-flop"
non-determinism. Codegen output must be a pure function of metadata identity.
Sorts an array of items by Sequence, then alphabetically by a type-appropriate name field, and finally by ID as a last-resort tiebreaker. This ensures that generated code maintains the same order across multiple CodeGen runs and across different database environments, even when Sequence values are identical (e.g., all 0 or all 1).
Why no
__mj_CreatedAttiebreaker: timestamps are set withGETUTCDATE()at insert time and diverge per environment (the dev who originally generated metadata gets one set of timestamps; a clean install via Flyway gets another, batched into the same SQL Server tick). Using them as a sort key made codegen output a function of DB-resident insertion history rather than of metadata identity, which is the root cause of the long-running "flip-flop" non-determinism. Codegen output must be a pure function of metadata identity.The alphabetical tiebreaker checks, in order: