]> git.ipfire.org Git - thirdparty/sqlalchemy/sqlalchemy.git/commitdiff
added a runtime-incrementing counter for default primary keys to testlib/schema for...
authorCatherine Devlin <catherine.devlin@gmail.com>
Wed, 19 Mar 2008 22:53:31 +0000 (22:53 +0000)
committerCatherine Devlin <catherine.devlin@gmail.com>
Wed, 19 Mar 2008 22:53:31 +0000 (22:53 +0000)
test/testlib/schema.py

index 152660380abd5c667ebc26f713681f57bcacc88f..7f6370482fac5b43462d7e3878a1b52b74b4d55e 100644 (file)
@@ -1,4 +1,5 @@
 from testlib import testing
+import itertools
 schema = None
 
 __all__ = 'Table', 'Column',
@@ -54,6 +55,8 @@ def Table(*args, **kw):
 
     return schema.Table(*args, **kw)
 
+generic_counter = itertools.count()
+
 def Column(*args, **kw):
     """A schema.Column wrapper/hook for dialect-specific tweaks."""
 
@@ -61,6 +64,8 @@ def Column(*args, **kw):
     if schema is None:
         from sqlalchemy import schema
 
-    # TODO: a Column that creates a Sequence automatically for PK columns,
-    # which would help Oracle tests
+    if testing.against('oracle'):
+        if kw.get('primary_key') == True and kw.get('default') == None: 
+            kw['default'] = generic_counter.next
+
     return schema.Column(*args, **kw)