Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error parsing generated ALTER COLUMN query #122

Closed
larkee opened this issue Sep 15, 2021 · 4 comments · Fixed by #124
Closed

Error parsing generated ALTER COLUMN query #122

larkee opened this issue Sep 15, 2021 · 4 comments · Fixed by #124
Assignees
Labels
api: spanner Issues related to the googleapis/python-spanner-sqlalchemy API. priority: p2 Moderately-important priority. Fix may not be included in next release. type: bug Error or flaw in code with unintended results or allowing sub-optimal usage patterns.

Comments

@larkee
Copy link
Contributor

larkee commented Sep 15, 2021

The generated query when calling alter_column is using the PostGres syntax:

ALTER TABLE table_id ALTER COLUMN column_id DROP NOT NULL

However, the Spanner way of doing this would be:

ALTER TABLE table_id ALTER COLUMN column_id column_type [null_constraint]

e.g. to remove NOT NULL

ALTER TABLE Venue ALTER COLUMN LastUpdateTime TIMESTAMP

e.g. to add NOT NULL

ALTER TABLE Venue ALTER COLUMN LastUpdateTime TIMESTAMP NOT NULL

See #118 (comment) for original example and error.

@larkee larkee added type: bug Error or flaw in code with unintended results or allowing sub-optimal usage patterns. priority: p2 Moderately-important priority. Fix may not be included in next release. labels Sep 15, 2021
@product-auto-label product-auto-label bot added the api: spanner Issues related to the googleapis/python-spanner-sqlalchemy API. label Sep 15, 2021
@geudrik
Copy link

geudrik commented Sep 16, 2021

Original report below for posterity as well


I think there are some additional bugs here / this successive issue should block #119

Error parsing Spanner DDL statement: ALTER TABLE ttp_mitre_enterprise ALTER COLUMN parent_id DROP NOT NULL

This is the alembic error I get using this branch trying to run a migration. In this case, the alembic migration is attempting to execute the following alembic code - altering a column and dropping the NOT NULL constraint

op.alter_column('ttp_mitre_enterprise', 'parent_id',
               existing_type=sa.String(length=2621440),
               nullable=True)

@geudrik
Copy link

geudrik commented Sep 22, 2021

@IlyaFaer any update on this?

@IlyaFaer
Copy link
Contributor

Looks like it's related to the Alembic API, not directly the SQLAlchemy dialect. Still, I see we're not the only one who have this problem - there is a solution already. Mimicking it in our API...

@geudrik
Copy link

geudrik commented Oct 8, 2021

@larkee we good for primetime? :D

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
api: spanner Issues related to the googleapis/python-spanner-sqlalchemy API. priority: p2 Moderately-important priority. Fix may not be included in next release. type: bug Error or flaw in code with unintended results or allowing sub-optimal usage patterns.
Projects
None yet
3 participants