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

support functional indexes with op.create_index() #222

Closed
sqlalchemy-bot opened this issue Aug 27, 2014 · 5 comments
Closed

support functional indexes with op.create_index() #222

sqlalchemy-bot opened this issue Aug 27, 2014 · 5 comments

Comments

@sqlalchemy-bot
Copy link

@sqlalchemy-bot sqlalchemy-bot commented Aug 27, 2014

Migrated issue, originally created by Michael Bayer (@zzzeek)

op.create_index() only accepts string column names. Particularly with autogenerate and issue #197, we need to be able to put expressions in here without needing a Column object lying around. So let's allow text():

op.create_index("foo", "table", text("lower('x')"), text("lower('y')"))
@sqlalchemy-bot
Copy link
Author

@sqlalchemy-bot sqlalchemy-bot commented Aug 27, 2014

Michael Bayer (@zzzeek) wrote:

Created https://bitbucket.org/zzzeek/sqlalchemy/issue/3174/support-text-sent-to-indexes on the SQLAlchemy side to fix this but for now we will work around it here.

@sqlalchemy-bot
Copy link
Author

@sqlalchemy-bot sqlalchemy-bot commented Aug 27, 2014

Michael Bayer (@zzzeek) wrote:

  • Added support for functional indexes when using the
    :meth:.Operations.create_index directive. Within the list of columns,
    the SQLAlchemy text() construct can be sent, embedding a literal
    SQL expression; the :meth:.Operations.create_index will perform some hackery
    behind the scenes to get the :class:.Index construct to cooperate.
    This works around some current limitations in :class:.Index
    which should be resolved on the SQLAlchemy side at some point.
    fixes #222

707f2d5

@sqlalchemy-bot
Copy link
Author

@sqlalchemy-bot sqlalchemy-bot commented Aug 27, 2014

Changes by Michael Bayer (@zzzeek):

  • changed status to closed
@sqlalchemy-bot
Copy link
Author

@sqlalchemy-bot sqlalchemy-bot commented Sep 20, 2014

Michael Bayer (@zzzeek) wrote:

  • Added support for functional indexes when using the
    :meth:.Operations.create_index directive. Within the list of columns,
    the SQLAlchemy text() construct can be sent, embedding a literal
    SQL expression; the :meth:.Operations.create_index will perform some hackery
    behind the scenes to get the :class:.Index construct to cooperate.
    This works around some current limitations in :class:.Index
    which should be resolved on the SQLAlchemy side at some point.
    fixes #222

c5be980

@sqlalchemy-bot
Copy link
Author

@sqlalchemy-bot sqlalchemy-bot commented Sep 8, 2016

Antti Haapala wrote:

This was the first Google result for Alembic functional indexes, just noting that the columns must be in a list (sequence):

op.create_index("foo", "table", [text("lower('x')"), text("lower('y')")])

otherwise one gets TypeError: 'TextClause' object is not iterable. (Took me some minutes to realize why, and well, in the
process I did upgrade my Alembic and SQLAlchemy...)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
1 participant