]> git.ipfire.org Git - thirdparty/sqlalchemy/sqlalchemy.git/commitdiff
add more docs to index, even though this seems to be a little redundant
authorMike Bayer <mike_mp@zzzcomputing.com>
Sun, 11 Aug 2013 06:22:36 +0000 (02:22 -0400)
committerMike Bayer <mike_mp@zzzcomputing.com>
Sun, 11 Aug 2013 06:22:54 +0000 (02:22 -0400)
lib/sqlalchemy/schema.py

index 6bd0283ff113a858010c682483204f479cb105b3..062c3c04e2b4e3f846f5259631bae53690187555 100644 (file)
@@ -2350,9 +2350,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::
 
@@ -2378,13 +2403,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.