Skip to content

Investigate PostgreSQL GENERATED ALWAYS AS IDENTITY fixture snapshots #106

Description

@nertzy

FixtureBuilder excludes database-generated expression columns because Rails fixtures cannot insert explicit values for them. PostgreSQL GENERATED ALWAYS AS IDENTITY columns have a similar constraint, but require a separate investigation.

Active Record exposes PostgreSQL identity metadata through column.identity?:

  • "a"GENERATED ALWAYS AS IDENTITY
  • "d"GENERATED BY DEFAULT AS IDENTITY

An ordinary PostgreSQL INSERT may supply an explicit value for BY DEFAULT, but rejects one for ALWAYS unless it uses OVERRIDING SYSTEM VALUE.

Rails’ fixture insertion currently excludes virtual? generated-expression columns but does not distinguish identity columns or add OVERRIDING SYSTEM VALUE. Therefore, a FixtureBuilder snapshot containing an explicit GENERATED ALWAYS AS IDENTITY value may fail while Rails loads it.

Investigation

  • Add a real PostgreSQL reproduction using GENERATED ALWAYS AS IDENTITY.
  • Confirm Active Record’s fixture-loading behavior on each supported Rails version.
  • Determine whether handling belongs upstream in Rails fixture insertion or in FixtureBuilder snapshot generation.
  • If FixtureBuilder owns the behavior, exclude only PostgreSQL column.identity? == "a" columns; retain serial, autoincrement, and GENERATED BY DEFAULT AS IDENTITY values.
  • Document the final compatibility contract and add regression coverage.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions