summaryrefslogtreecommitdiff
path: root/lib/sqlalchemy/schema.py
diff options
context:
space:
mode:
authorMike Bayer <mike_mp@zzzcomputing.com>2013-08-11 02:22:36 -0400
committerMike Bayer <mike_mp@zzzcomputing.com>2013-08-11 02:22:36 -0400
commit73c8658831c07f78dc3186215fbfd6e5721e4d90 (patch)
tree303cf85820bcd2cd0fccb2daeea1f908636e682b /lib/sqlalchemy/schema.py
parent9dcdf7ff735bea9836c366b041727ebd94d554b7 (diff)
downloadsqlalchemy-73c8658831c07f78dc3186215fbfd6e5721e4d90.tar.gz
add more docs to index, even though this seems to be a little redundant
Diffstat (limited to 'lib/sqlalchemy/schema.py')
-rw-r--r--lib/sqlalchemy/schema.py39
1 files changed, 29 insertions, 10 deletions
diff --git a/lib/sqlalchemy/schema.py b/lib/sqlalchemy/schema.py
index 83d99f9c3..9550f0264 100644
--- a/lib/sqlalchemy/schema.py
+++ b/lib/sqlalchemy/schema.py
@@ -2451,9 +2451,34 @@ class UniqueConstraint(ColumnCollectionConstraint):
class Index(ColumnCollectionMixin, SchemaItem):
"""A table-level INDEX.
- Defines a composite (one or more column) INDEX. For a no-frills, single
- column index, adding ``index=True`` to the ``Column`` definition is
- a shorthand equivalent for an unnamed, single column :class:`.Index`.
+ Defines a composite (one or more column) INDEX.
+
+ E.g.::
+
+ sometable = Table("sometable", metadata,
+ Column("name", String(50)),
+ Column("address", String(100))
+ )
+
+ Index("some_index", sometable.c.name)
+
+ For a no-frills, single column index, adding
+ :class:`.Column` also supports ``index=True``::
+
+ sometable = Table("sometable", metadata,
+ Column("name", String(50), index=True)
+ )
+
+ For a composite index, multiple columns can be specified::
+
+ Index("some_index", sometable.c.name, sometable.c.address)
+
+ Functional indexes are supported as well, keeping in mind that at least
+ one :class:`.Column` must be present::
+
+ Index("some_index", func.lower(sometable.c.name))
+
+ .. versionadded:: 0.8 support for functional and expression-based indexes.
.. seealso::
@@ -2479,13 +2504,7 @@ class Index(ColumnCollectionMixin, SchemaItem):
The name of the index
:param \*expressions:
- Column expressions to include in the index. The expressions
- are normally instances of :class:`.Column`, but may also
- be arbitrary SQL expressions which ultmately refer to a
- :class:`.Column`.
-
- .. versionadded:: 0.8 :class:`.Index` supports SQL expressions as
- well as plain columns.
+ Column or SQL expressions.
:param unique:
Defaults to False: create a unique index.