summaryrefslogtreecommitdiff
path: root/lib/sqlalchemy/databases/postgres.py
diff options
context:
space:
mode:
authorAnts Aasma <ants.aasma@gmail.com>2007-10-01 16:29:26 +0000
committerAnts Aasma <ants.aasma@gmail.com>2007-10-01 16:29:26 +0000
commitfe3178e22457556fc98f577468f0bb24d28ce300 (patch)
tree755f5c0cc4df17c2bc6561c708dfadc52ba402c7 /lib/sqlalchemy/databases/postgres.py
parent0dde728591cb083e351cf1ff1998aaf1883ab7a1 (diff)
downloadsqlalchemy-fe3178e22457556fc98f577468f0bb24d28ce300.tar.gz
Make the postgres_where attribute to Index private to postgres module by using a kwargs attribute on the Index.
Diffstat (limited to 'lib/sqlalchemy/databases/postgres.py')
-rw-r--r--lib/sqlalchemy/databases/postgres.py13
1 files changed, 11 insertions, 2 deletions
diff --git a/lib/sqlalchemy/databases/postgres.py b/lib/sqlalchemy/databases/postgres.py
index 76f17bb5b..9292e6ea4 100644
--- a/lib/sqlalchemy/databases/postgres.py
+++ b/lib/sqlalchemy/databases/postgres.py
@@ -4,6 +4,14 @@
# This module is part of SQLAlchemy and is released under
# the MIT License: http://www.opensource.org/licenses/mit-license.php
+"""Support for the PostgreSQL database.
+
+PostgreSQL supports partial indexes. To create them pass a posgres_where
+option to the Index constructor::
+
+ Index('my_index', my_table.c.id, postgres_where=tbl.c.value > 10)
+"""
+
import re, random, warnings, string
from sqlalchemy import sql, schema, exceptions, util
@@ -622,8 +630,9 @@ class PGSchemaGenerator(compiler.SchemaGenerator):
% (preparer.format_index(index),
preparer.format_table(index.table),
string.join([preparer.format_column(c) for c in index.columns], ', ')))
- if index.postgres_where is not None:
- compiler = self._compile(index.postgres_where, None)
+ whereclause = index.kwargs.get('postgres_where', None)
+ if whereclause is not None:
+ compiler = self._compile(whereclause, None)
# this might belong to the compiler class
inlined_clause = str(compiler) % dict((key,bind.value) for key,bind in compiler.binds.iteritems())
self.append(" WHERE " + inlined_clause)