Hi,

I've attached a tiny patch which adds support for index specification
like this:

sqlalchemy.schema.Index('ix_name', 'column', postgresql_ops = {'column':
'text_pattern_ops'})

resulting in:
    "ix_name" btree (column text_pattern_ops)

Operator classes for indexes are documented here:
http://www.postgresql.org/docs/9.0/static/indexes-opclass.html

How do you like it?

regards,
Filip Zyzniewski
Tefnet

-- 
You received this message because you are subscribed to the Google Groups 
"sqlalchemy" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/sqlalchemy?hl=en.

diff --git a/lib/python2.7/site-packages/SQLAlchemy-0.7.1-py2.7.egg/sqlalchemy/dialects/postgresql/base.py b/lib/python2.7/site-packages/SQLAlchemy-0.7.1-py2.7.egg/sqlalchemy/dialects/postgresql/base.py
index 3193cde..39dfd39 100644
--- a/lib/python2.7/site-packages/SQLAlchemy-0.7.1-py2.7.egg/sqlalchemy/dialects/postgresql/base.py
+++ b/lib/python2.7/site-packages/SQLAlchemy-0.7.1-py2.7.egg/sqlalchemy/dialects/postgresql/base.py
@@ -570,11 +570,12 @@ class PGDDLCompiler(compiler.DDLCompiler):
         text = "CREATE "
         if index.unique:
             text += "UNIQUE "
+        ops = index.kwargs.get('postgresql_ops', {})
         text += "INDEX %s ON %s (%s)" \
                 % (preparer.quote(
                     self._index_identifier(index.name), index.quote),
                    preparer.format_table(index.table),
-                   ', '.join([preparer.format_column(c) 
+                   ', '.join(['%s %s' % (preparer.format_column(c), ops.get(c.name, ''))
                                 for c in index.columns]))
 
         if "postgres_where" in index.kwargs:

Reply via email to