summaryrefslogtreecommitdiff
path: root/lib/sqlalchemy/dialects/postgresql/base.py
diff options
context:
space:
mode:
authorMike Bayer <mike_mp@zzzcomputing.com>2013-01-16 21:04:32 -0500
committerMike Bayer <mike_mp@zzzcomputing.com>2013-01-16 21:04:32 -0500
commit7fedf9958687222a9e3c2fc4d50983711dbb3d52 (patch)
tree921320393422f906e75451376b41b3406abacef4 /lib/sqlalchemy/dialects/postgresql/base.py
parent87002643407f886f13a3b53283ea0b6dafa695cc (diff)
downloadsqlalchemy-7fedf9958687222a9e3c2fc4d50983711dbb3d52.tar.gz
:class:`.Index` now supports arbitrary SQL expressions and/or
functions, in addition to straight columns. Common modifiers include using ``somecolumn.desc()`` for a descending index and ``func.lower(somecolumn)`` for a case-insensitive index, depending on the capabilities of the target backend. [ticket:695]
Diffstat (limited to 'lib/sqlalchemy/dialects/postgresql/base.py')
-rw-r--r--lib/sqlalchemy/dialects/postgresql/base.py22
1 files changed, 11 insertions, 11 deletions
diff --git a/lib/sqlalchemy/dialects/postgresql/base.py b/lib/sqlalchemy/dialects/postgresql/base.py
index 81d2079c0..afbb23e15 100644
--- a/lib/sqlalchemy/dialects/postgresql/base.py
+++ b/lib/sqlalchemy/dialects/postgresql/base.py
@@ -962,13 +962,13 @@ class PGDDLCompiler(compiler.DDLCompiler):
def visit_create_index(self, create):
preparer = self.preparer
index = create.element
+ self._verify_index_table(index)
text = "CREATE "
if index.unique:
text += "UNIQUE "
- ops = index.kwargs.get('postgresql_ops', {})
text += "INDEX %s ON %s " % (
- preparer.quote(
- self._index_identifier(index.name), index.quote),
+ self._prepared_index_name(index,
+ include_schema=True),
preparer.format_table(index.table)
)
@@ -976,20 +976,20 @@ class PGDDLCompiler(compiler.DDLCompiler):
using = index.kwargs['postgresql_using']
text += "USING %s " % preparer.quote(using, index.quote)
+ ops = index.kwargs.get('postgresql_ops', {})
text += "(%s)" \
% (
', '.join([
- preparer.format_column(c) +
+ self.sql_compiler.process(expr, include_table=False) +
+
+
(c.key in ops and (' ' + ops[c.key]) or '')
- for c in index.columns])
+
+
+ for expr, c in zip(index.expressions, index.columns)])
)
- if "postgres_where" in index.kwargs:
- whereclause = index.kwargs['postgres_where']
- util.warn_deprecated(
- "The 'postgres_where' argument has been renamed "
- "to 'postgresql_where'.")
- elif 'postgresql_where' in index.kwargs:
+ if 'postgresql_where' in index.kwargs:
whereclause = index.kwargs['postgresql_where']
else:
whereclause = None