diff options
author | jakeogh <github.com@v6y.net> | 2015-06-27 20:49:46 +0000 |
---|---|---|
committer | jakeogh <github.com@v6y.net> | 2015-06-27 20:49:46 +0000 |
commit | 66b9a71ce7457b618e9040c1c0bbc2dbd1966354 (patch) | |
tree | debc66cd8a536749d7c7e7ff3145eef1aac1fdcd /lib/sqlalchemy/sql/schema.py | |
parent | 85ebe01349e0b4314d9e25cacc6701d6fed7b87e (diff) | |
download | sqlalchemy-pr/186.tar.gz |
add CYCLE support to Sequence() and docstrings for NO MINVALUE and NO MAXVALUEpr/186
Diffstat (limited to 'lib/sqlalchemy/sql/schema.py')
-rw-r--r-- | lib/sqlalchemy/sql/schema.py | 29 |
1 files changed, 27 insertions, 2 deletions
diff --git a/lib/sqlalchemy/sql/schema.py b/lib/sqlalchemy/sql/schema.py index ccec74a35..ecfa57676 100644 --- a/lib/sqlalchemy/sql/schema.py +++ b/lib/sqlalchemy/sql/schema.py @@ -2041,8 +2041,9 @@ class Sequence(DefaultGenerator): is_sequence = True def __init__(self, name, start=None, increment=None, minvalue=None, - maxvalue=None, nominvalue=None, nomaxvalue=None, schema=None, - optional=False, quote=None, metadata=None, quote_schema=None, + maxvalue=None, nominvalue=None, nomaxvalue=None, cycle=None, + schema=None, optional=False, quote=None, metadata=None, + quote_schema=None, for_update=False): """Construct a :class:`.Sequence` object. @@ -2069,6 +2070,26 @@ class Sequence(DefaultGenerator): the clause is omitted, which on most platforms indicates a maxvalue of 2^63-1 and -1 for ascending and descending sequences, respectively. + :param nominvalue: no minimum value of the sequence. This + value is used when the CREATE SEQUENCE command is emitted to + the database as the value of the "NO MINVALUE" clause. If ``None``, + the clause is omitted, which on most platforms indicates a + minvalue of 1 and -2^63-1 for ascending and descending sequences, + respectively. + :param nomaxvalue: no maximum value of the sequence. This + value is used when the CREATE SEQUENCE command is emitted to + the database as the value of the "NO MAXVALUE" clause. If ``None``, + the clause is omitted, which on most platforms indicates a + maxvalue of 2^63-1 and -1 for ascending and descending sequences, + respectively. + :param cycle: allows the sequence to wrap around when the maxvalue + or minvalue has been reached by an ascending or descending sequence + respectively. This value is used when the CREATE SEQUENCE command + is emitted to the database as the "CYCLE" clause. If the limit is + reached, the next number generated will be the minvalue or maxvalue, + respectively. If cycle=False (the default) any calls to nextval + after the sequence has reached its maximum value will return an + error. :param schema: Optional schema name for the sequence, if located in a schema other than the default. :param optional: boolean value, when ``True``, indicates that this @@ -2114,6 +2135,10 @@ class Sequence(DefaultGenerator): self.start = start self.increment = increment self.minvalue = minvalue + self.maxvalue = maxvalue + self.nominvalue = nominvalue + self.nomaxvalue = nomaxvalue + self.cycle = cycle self.optional = optional if metadata is not None and schema is None and metadata.schema: self.schema = schema = metadata.schema |