Skip to content

Make OVERRIDING SYSTEM VALUE the default? #406

Description

@isovector

Hi there,

I've got a table whose primary key is generated via:

mkConstraints (TableSchema (QualifiedName table_name _) table) (AutoInc f) =
  sql $ BS8.pack $ unwords
    [ "ALTER TABLE"
    , table_name
    , "ALTER COLUMN"
    , nameToString $ f table
    , "ADD GENERATED ALWAYS AS IDENTITY"
    ]

This works fine and dandy whenever i use unsafeDefault to insert the key. But I'm now doing a backfill from an existing datasource, and require non-defaults for these keys. Attempting to run the (Haskell-well-typed) query results in:

ResultError (ServerError "428C9" "cannot insert a non-DEFAULT value into column \"user_id\"" (Just "Column \"user_id\" is an identity column defined as GENERATED ALWAYS.") (Just "Use OVERRIDING SYSTEM VALUE to override.") Nothing)

Explicitly setting OVERRIDING SYSTEM VALUE when generating inserts seems reasonable to me. If you're going to make me fill it in myself, you might as well respect what I stick in if it isn't DEFAULT :)

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

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions