summaryrefslogtreecommitdiff
path: root/lib/sqlalchemy/engine
diff options
context:
space:
mode:
authorJason Kirtland <jek@discorporate.us>2007-10-23 01:47:21 +0000
committerJason Kirtland <jek@discorporate.us>2007-10-23 01:47:21 +0000
commitd89b2acdd7218ca179844c05be9d8f888d0c7ee6 (patch)
tree348cf9bda3cef0f75181f103aafe650fc2566b4b /lib/sqlalchemy/engine
parent8dfff3888f4ab28487a573cc5617c818c3975c2d (diff)
downloadsqlalchemy-d89b2acdd7218ca179844c05be9d8f888d0c7ee6.tar.gz
Added support for dialects that have both sequences and autoincrementing PKs.
Diffstat (limited to 'lib/sqlalchemy/engine')
-rw-r--r--lib/sqlalchemy/engine/base.py13
-rw-r--r--lib/sqlalchemy/engine/default.py15
2 files changed, 22 insertions, 6 deletions
diff --git a/lib/sqlalchemy/engine/base.py b/lib/sqlalchemy/engine/base.py
index 5f3975684..131f50540 100644
--- a/lib/sqlalchemy/engine/base.py
+++ b/lib/sqlalchemy/engine/base.py
@@ -12,9 +12,9 @@ higher-level statement-construction, connection-management, execution
and result contexts.
"""
+import StringIO, sys
from sqlalchemy import exceptions, schema, util, types, logging
from sqlalchemy.sql import expression, visitors
-import StringIO, sys
class Dialect(object):
@@ -79,9 +79,14 @@ class Dialect(object):
Indicate whether the dialect properly implements rowcount for ``UPDATE`` and ``DELETE`` statements
when executed via executemany.
- preexecute_sequences
- Indicate if the dialect should pre-execute sequences on primary key columns during an INSERT,
- if it's desired that the new row's primary key be available after execution.
+ preexecute_pk_sequences
+ Indicate if the dialect should pre-execute sequences on primary key
+ columns during an INSERT, if it's desired that the new row's primary key
+ be available after execution.
+
+ supports_pk_autoincrement
+ Indicates if the dialect should allow the database to passively assign
+ a primary key column value.
"""
def create_connect_args(self, url):
diff --git a/lib/sqlalchemy/engine/default.py b/lib/sqlalchemy/engine/default.py
index 1a15c8b8d..d826b97fa 100644
--- a/lib/sqlalchemy/engine/default.py
+++ b/lib/sqlalchemy/engine/default.py
@@ -31,7 +31,8 @@ class DefaultDialect(base.Dialect):
max_identifier_length = 9999
supports_sane_rowcount = True
supports_sane_multi_rowcount = True
- preexecute_sequences = False
+ preexecute_pk_sequences = False
+ supports_pk_autoincrement = True
def __init__(self, convert_unicode=False, encoding='utf-8', default_paramstyle='named', paramstyle=None, dbapi=None, **kwargs):
self.convert_unicode = convert_unicode
@@ -47,7 +48,17 @@ class DefaultDialect(base.Dialect):
self.paramstyle = default_paramstyle
self.positional = self.paramstyle in ('qmark', 'format', 'numeric')
self.identifier_preparer = self.preparer(self)
-
+
+ # preexecute_sequences was renamed preexecute_pk_sequences. If a
+ # subclass has the older property, proxy the new name to the subclass's
+ # property.
+ # TODO: remove @ 0.5.0
+ if (hasattr(self, 'preexecute_sequences') and
+ isinstance(getattr(type(self), 'preexecute_pk_sequences'), bool)):
+ setattr(type(self), 'preexecute_pk_sequences',
+ property(lambda s: s.preexecute_sequences, doc=(
+ "Proxy to deprecated preexecute_sequences attribute.")))
+
def dbapi_type_map(self):
# most DB-APIs have problems with this (such as, psycocpg2 types
# are unhashable). So far Oracle can return it.