From: Jason Kirtland Date: Thu, 4 Oct 2007 21:03:29 +0000 (+0000) Subject: - Sequences gain a basic dialect-specific kwargs bucket, like Tables. X-Git-Tag: rel_0_4_0~72 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=af0ca25d10ea505df6c5b740951e88e9af36bd60;p=thirdparty%2Fsqlalchemy%2Fsqlalchemy.git - Sequences gain a basic dialect-specific kwargs bucket, like Tables. --- diff --git a/lib/sqlalchemy/schema.py b/lib/sqlalchemy/schema.py index 8ca5567e47..29a28e54b6 100644 --- a/lib/sqlalchemy/schema.py +++ b/lib/sqlalchemy/schema.py @@ -768,9 +768,10 @@ class ColumnDefault(DefaultGenerator): return "ColumnDefault(%s)" % repr(self.arg) class Sequence(DefaultGenerator): - """Represent a sequence, which applies to Oracle and Postgres databases.""" + """Represents a named sequence.""" - def __init__(self, name, start = None, increment = None, schema=None, optional=False, quote=False, **kwargs): + def __init__(self, name, start=None, increment=None, schema=None, + optional=False, quote=False, **kwargs): super(Sequence, self).__init__(**kwargs) self.name = name self.start = start @@ -778,22 +779,28 @@ class Sequence(DefaultGenerator): self.optional=optional self.quote = quote self.schema = schema + self.kwargs = kwargs def __repr__(self): return "Sequence(%s)" % ', '.join( [repr(self.name)] + - ["%s=%s" % (k, repr(getattr(self, k))) for k in ['start', 'increment', 'optional']]) + ["%s=%s" % (k, repr(getattr(self, k))) + for k in ['start', 'increment', 'optional']]) def _set_parent(self, column): super(Sequence, self)._set_parent(column) column.sequence = self def create(self, bind=None, checkfirst=True): + """Creates this sequence in the database.""" + if bind is None: bind = self._get_bind(raiseerr=True) bind.create(self, checkfirst=checkfirst) def drop(self, bind=None, checkfirst=True): + """Drops this sequence from the database.""" + if bind is None: bind = self._get_bind(raiseerr=True) bind.drop(self, checkfirst=checkfirst)