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

postgres dialect does produces wrong sql for schema names with extra dots #230

Closed
sqlalchemy-bot opened this issue Oct 3, 2014 · 4 comments
Labels
bug Something isn't working external SQLAlchemy issues the issue is in SQLAlchemy, not here in alembic

Comments

@sqlalchemy-bot
Copy link

Migrated issue, originally created by John Janssen (@Sindol)

In a recent revision I tried to add a column to a certain schema in my postgres database, with a code something like this:

from alembic import op
import sqlalchemy as sa

op.add_column(mytablename, sa.Column(mycolname, sa.String), schema=myschemaname)

When myschemaname already has a dot (".") in it, this fails. For example for schemaname "my.schema" it produces:

ALTER TABLE "my".schema.mytablename ADD COLUMN mycolname VARCHAR

This returns an exception:
sqlalchemy.exc.NotSupportedError: (NotSupportedError) cross-database references are not implemented

Correct query would be:

ALTER TABLE "my.schema".mytablename ADD COLUMN mycolname VARCHAR
@sqlalchemy-bot
Copy link
Author

Changes by John Janssen (@Sindol):

  • edited description

@sqlalchemy-bot
Copy link
Author

Michael Bayer (@zzzeek) wrote:

5bb97a4

@sqlalchemy-bot
Copy link
Author

Changes by Michael Bayer (@zzzeek):

  • changed status to closed

@sqlalchemy-bot
Copy link
Author

Michael Bayer (@zzzeek) wrote:

here's the format:

from sqlalchemy.sql.schema import quoted_name
op.add_column("somename", sa.Column("colname", sa.String), schema=quoted_name("some.schema", quote=True))

@sqlalchemy-bot sqlalchemy-bot added external SQLAlchemy issues the issue is in SQLAlchemy, not here in alembic bug Something isn't working labels Nov 27, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working external SQLAlchemy issues the issue is in SQLAlchemy, not here in alembic
Projects
None yet
Development

No branches or pull requests

1 participant