From d0881de1c480cf7bf46c93608b7f2dd66f2e2f37 Mon Sep 17 00:00:00 2001 From: Mike Bayer Date: Tue, 10 Mar 2015 14:18:35 -0400 Subject: [PATCH] - changelog / doc for sqlite partial indexes (cherry picked from commit 6ac0555eaa6363ac9d0ad6566248dd294ad61d9e) --- doc/build/changelog/changelog_09.rst | 11 +++++++++++ lib/sqlalchemy/dialects/sqlite/base.py | 20 ++++++++++++++++++++ 2 files changed, 31 insertions(+) diff --git a/doc/build/changelog/changelog_09.rst b/doc/build/changelog/changelog_09.rst index c7bd272f28..1f583c44a0 100644 --- a/doc/build/changelog/changelog_09.rst +++ b/doc/build/changelog/changelog_09.rst @@ -14,6 +14,17 @@ .. changelog:: :version: 0.9.9 + .. change:: + :tags: feature, sqlite + :pullreq: bitbucket:42 + + Added support for partial indexes (e.g. with a WHERE clause) on + SQLite. Pull request courtesy Kai Groner. + + .. seealso:: + + :ref:`sqlite_partial_index` + .. change:: :tags: bug, orm :tickets: 3310 diff --git a/lib/sqlalchemy/dialects/sqlite/base.py b/lib/sqlalchemy/dialects/sqlite/base.py index 9881eea64b..189bce86a0 100644 --- a/lib/sqlalchemy/dialects/sqlite/base.py +++ b/lib/sqlalchemy/dialects/sqlite/base.py @@ -245,6 +245,26 @@ lookup is used instead: .. versionadded:: 0.9.3 Support for SQLite type affinity rules when reflecting columns. + +.. _sqlite_partial_index: + +Partial Indexes +=============== + +A partial index, e.g. one which uses a WHERE clause, can be specified +with the DDL system using the argument ``sqlite_where``:: + + tbl = Table('testtbl', m, Column('data', Integer)) + idx = Index('test_idx1', tbl.c.data, + sqlite_where=and_(tbl.c.data > 5, tbl.c.data < 10)) + +The index will be rendered at create time as:: + + CREATE INDEX test_idx1 ON testtbl (data) + WHERE data > 5 AND data < 10 + +.. versionadded:: 0.9.9 + """ import datetime -- 2.47.3