Skip to content

PATCH /columns rewrites GENERATED ALWAYS identity to BY DEFAULT when identity_generation is omitted #1114

Description

@hsusul

Describe the bug

PATCH /columns/:id (and PostgresMeta.columns.update) rewrites a GENERATED ALWAYS identity column to GENERATED BY DEFAULT whenever identity_generation is omitted.

Updating only a comment, name, nullability, or type therefore changes identity generation as a side effect.

To Reproduce

const created = await pgMeta.columns.create({
  table_id,
  name: 'id',
  type: 'int8',
  is_identity: true,
  identity_generation: 'ALWAYS',
})

const updated = await pgMeta.columns.update(created.data.id, { comment: 'pk' })
// updated.data.identity_generation === 'BY DEFAULT'

Expected behavior

Omitting identity_generation leaves generation unchanged (ALWAYS stays ALWAYS). That is what the state table in PostgresMetaColumns.update already documents: when the column is already identity and identity_generation is undefined, emit no SET GENERATED.

Actual behavior

The parameter default identity_generation = 'BY DEFAULT' makes the === undefined branch unreachable, so every update of an identity column emits SET GENERATED BY DEFAULT.

Additional context

POST /columns should keep defaulting omitted identity_generation to BY DEFAULT (that was #77). The update-path default is the bug.

  • Library: @supabase/postgres-meta
  • Branch analyzed: master (641831e)

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