Skip to content

ALTER COLUMN DDL Removes DEFAULTs #732

@waltaskew

Description

@waltaskew

The ALTER COLUMN DDL does not include existing DEFAULT values, which causes DEFAULT values to be dropped when running it.

For ALTER COLUMN DDL, Spanner always requires the full table definition. DDL like:

ALTER TABLE tbl ALTER COLUMN col STRING(MAX)

would remove any previously defined DEFAULT. The full definition needs to be present:

ALTER TABLE tbl ALTER COLUMN col STRING(MAX) DEFAULT the_default

to avoid dropping previously defined defaults. The DDL emitted by visit_column_type and visit_column_nullable should respect element.existing_server_default if it's passed in.

Environment details

  • Programming language: Python
  • OS: linux
  • Language runtime version: 3.8
  • Package version: 1.14.0

Steps to reproduce

create an alembic alter column migration like:

    op.alter_column(
        "tbl",
        "id",
        existing_type=sa.String(length=2621440),
        type_=sa.String(length=50),
        existing_nullable=False,
        existing_server_default=sa.text("GENERATE_UUID()"),
        schema="design_raw",
    )

Metadata

Metadata

Assignees

Labels

api: spannerIssues related to the googleapis/python-spanner-sqlalchemy API.priority: p2Moderately-important priority. Fix may not be included in next release.type: bugError or flaw in code with unintended results or allowing sub-optimal usage patterns.

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions