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)
Describe the bug
PATCH /columns/:id(andPostgresMeta.columns.update) rewrites aGENERATED ALWAYSidentity column toGENERATED BY DEFAULTwheneveridentity_generationis omitted.Updating only a comment, name, nullability, or type therefore changes identity generation as a side effect.
To Reproduce
Expected behavior
Omitting
identity_generationleaves generation unchanged (ALWAYSstaysALWAYS). That is what the state table inPostgresMetaColumns.updatealready documents: when the column is already identity andidentity_generationis undefined, emit noSET GENERATED.Actual behavior
The parameter default
identity_generation = 'BY DEFAULT'makes the=== undefinedbranch unreachable, so every update of an identity column emitsSET GENERATED BY DEFAULT.Additional context
POST /columnsshould keep defaulting omittedidentity_generationtoBY DEFAULT(that was #77). The update-path default is the bug.@supabase/postgres-metamaster(641831e)