diff options
| author | David Moore <davidm@j5int.com> | 2017-07-05 15:06:49 -0400 |
|---|---|---|
| committer | Mike Bayer <mike_mp@zzzcomputing.com> | 2017-07-05 16:23:13 -0400 |
| commit | acabfc72ad79e6c049e52011b69dba65e7aae026 (patch) | |
| tree | f217ba80dd15e621e3e456ec2508c170379d482a /lib/sqlalchemy | |
| parent | 6d6ab57c2b7feecb33207ff3a3273fefa7123acd (diff) | |
| download | sqlalchemy-acabfc72ad79e6c049e52011b69dba65e7aae026.tar.gz | |
Add support for CACHE and ORDER to sequences
Added new keywords :paramref:`.Sequence.cache` and
:paramref:`.Sequence.order` to :class:`.Sequence`, to allow rendering
of the CACHE parameter understood by Oracle and PostgreSQL, and the
ORDER parameter understood by Oracle. Pull request
courtesy David Moore.
Change-Id: I082c3f8ef56ef89dbaad5da9d5695be5313b0614
Pull-request: https://bitbucket.org/zzzeek/sqlalchemy/pull-requests/96
(cherry picked from commit faa6609dac2ce6e55e0f690df3ba88c13133ec5c)
Diffstat (limited to 'lib/sqlalchemy')
| -rw-r--r-- | lib/sqlalchemy/engine/interfaces.py | 2 | ||||
| -rw-r--r-- | lib/sqlalchemy/sql/compiler.py | 4 | ||||
| -rw-r--r-- | lib/sqlalchemy/sql/schema.py | 19 |
3 files changed, 22 insertions, 3 deletions
diff --git a/lib/sqlalchemy/engine/interfaces.py b/lib/sqlalchemy/engine/interfaces.py index d0eff1cb1..afa3c0fe2 100644 --- a/lib/sqlalchemy/engine/interfaces.py +++ b/lib/sqlalchemy/engine/interfaces.py @@ -254,7 +254,7 @@ class Dialect(object): a dictionary of the form {'name' : str, 'start' :int, 'increment': int, 'minvalue': int, 'maxvalue': int, 'nominvalue': bool, 'nomaxvalue': bool, - 'cycle': bool} + 'cycle': bool, 'cache': int, 'order': bool} Additional column attributes may be present. """ diff --git a/lib/sqlalchemy/sql/compiler.py b/lib/sqlalchemy/sql/compiler.py index bfa22c206..6768c062e 100644 --- a/lib/sqlalchemy/sql/compiler.py +++ b/lib/sqlalchemy/sql/compiler.py @@ -2483,6 +2483,10 @@ class DDLCompiler(Compiled): text += " NO MINVALUE" if create.element.nomaxvalue is not None: text += " NO MAXVALUE" + if create.element.cache is not None: + text += " CACHE %d" % create.element.cache + if create.element.order is True: + text += " ORDER" if create.element.cycle is not None: text += " CYCLE" return text diff --git a/lib/sqlalchemy/sql/schema.py b/lib/sqlalchemy/sql/schema.py index 078487bec..592dc390d 100644 --- a/lib/sqlalchemy/sql/schema.py +++ b/lib/sqlalchemy/sql/schema.py @@ -2120,8 +2120,8 @@ class Sequence(DefaultGenerator): def __init__(self, name, start=None, increment=None, minvalue=None, maxvalue=None, nominvalue=None, nomaxvalue=None, cycle=None, - schema=None, optional=False, quote=None, metadata=None, - quote_schema=None, + schema=None, cache=None, order=None, optional=False, + quote=None, metadata=None, quote_schema=None, for_update=False): """Construct a :class:`.Sequence` object. @@ -2188,6 +2188,19 @@ class Sequence(DefaultGenerator): schema name when a :class:`.MetaData` is also present are the same as that of :paramref:`.Table.schema`. + :param cache: optional integer value; number of future values in the + sequence which are calculated in advance. Renders the CACHE keyword + understood by Oracle and PostgreSQL. + + .. versionadded:: 1.1.12 + + :param order: optional boolean value; if true, renders the + ORDER keyword, understood by Oracle, indicating the sequence is + definitively ordered. May be necessary to provide deterministic + ordering using Oracle RAC. + + .. versionadded:: 1.1.12 + :param optional: boolean value, when ``True``, indicates that this :class:`.Sequence` object only needs to be explicitly generated on backends that don't provide another way to generate primary @@ -2243,6 +2256,8 @@ class Sequence(DefaultGenerator): self.nominvalue = nominvalue self.nomaxvalue = nomaxvalue self.cycle = cycle + self.cache = cache + self.order = order self.optional = optional if schema is BLANK_SCHEMA: self.schema = schema = None |
