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

text() construct generated for autogen on create_index w/ real column expression includes table name, fails #337

Closed
sqlalchemy-bot opened this issue Oct 30, 2015 · 10 comments
Labels
autogenerate - rendering bug Something isn't working

Comments

@sqlalchemy-bot
Copy link

Migrated issue, originally created by roy enjoy (@kirpit)

The following operation is failing and postgresql complains about its syntax.

op.create_index('ix_publish_at', 'cms_video', [sa.text(u'cms_video.publish_at DESC')], unique=False)

sqlalchemy.exc.ProgrammingError: (psycopg2.ProgrammingError) syntax error at or near "DESC" LINE 1: ...INDEX ix_publish_at ON cms_video (cms_video.publish_at DESC)

publish_at is a simply DateTime field and here is the index definition:
Index('ix_publish_at', publish_at.desc())

I created the revision file with --autogenerate.

I found an exact same question but it seems he had old version of psql running. My postgresql was installed with brew and its version is 9.4.4 that should be enough to support desc indexes. Tried with alembic==0.8.3, I don't know what is wrong.

@sqlalchemy-bot
Copy link
Author

Michael Bayer (@zzzeek) wrote:

hi there -

this is a usage question - please use the mailing list for questions thanks!

the list passed to create_index are column expressions, they aren't table qualified:

op.create_index(
    'ix_publish_at', 'cms_video',
    [sa.text("publish_at DESC")], unique=False)

@sqlalchemy-bot
Copy link
Author

Changes by Michael Bayer (@zzzeek):

  • added labels: invalid

@sqlalchemy-bot
Copy link
Author

Michael Bayer (@zzzeek) wrote:

oh, autogenerate is generating this, fine. you need to correct this manually for now.

@sqlalchemy-bot
Copy link
Author

Changes by Michael Bayer (@zzzeek):

  • removed labels: invalid

@sqlalchemy-bot
Copy link
Author

Changes by Michael Bayer (@zzzeek):

  • added labels: autogenerate - rendering

@sqlalchemy-bot
Copy link
Author

Changes by Michael Bayer (@zzzeek):

  • changed title from "Error creating DESC index on Postgresql" to "text() construct generated for autogen on create_i"

@sqlalchemy-bot
Copy link
Author

Michael Bayer (@zzzeek) wrote:

seems like postgres accepts an expression like:

CREATE INDEX ix_publish_at ON cms_video (lower(cms_video.publish_at))

but we can remove the table qualification on these as well.

@sqlalchemy-bot
Copy link
Author

Michael Bayer (@zzzeek) wrote:

e88a366

@sqlalchemy-bot
Copy link
Author

Changes by Michael Bayer (@zzzeek):

  • changed status to closed

@sqlalchemy-bot
Copy link
Author

roy enjoy (@kirpit) wrote:

Thanks @zzzeek, much appreciated!

@sqlalchemy-bot sqlalchemy-bot added autogenerate - rendering 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
autogenerate - rendering bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant