Member Junction
    Preparing search index...
    • 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.

      The alphabetical tiebreaker checks, in order:

      • Value (EntityFieldValueInfo)
      • Name (EntityFieldInfo)
      • RelatedEntityJoinField (EntityRelationshipInfo)
      • ID (universal last resort — all types have this)

      Type Parameters

      • T extends {
            __mj_CreatedAt?: Date;
            ID?: string;
            Name?: string;
            RelatedEntityJoinField?: string;
            Sequence: number;
            Value?: string;
        }

      Parameters

      • items: T[]

        Array of items that have Sequence and optional name properties

      Returns T[]

      A new sorted array