From f3fc5840554c1b56f91479d357f81f86faec8a34 Mon Sep 17 00:00:00 2001 From: Mike Bayer Date: Sun, 11 Aug 2013 02:22:36 -0400 Subject: [PATCH] add more docs to index, even though this seems to be a little redundant --- lib/sqlalchemy/schema.py | 39 +++++++++++++++++++++++++++++---------- 1 file changed, 29 insertions(+), 10 deletions(-) diff --git a/lib/sqlalchemy/schema.py b/lib/sqlalchemy/schema.py index 6bd0283ff1..062c3c04e2 100644 --- a/lib/sqlalchemy/schema.py +++ b/lib/sqlalchemy/schema.py @@ -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. -- 2.47.2