The internal BackRef() is gone and backref() returns a plain
tuple that is understood by RelationProperty.
+ - The version_id_col feature on mapper() will raise a warning when
+ used with dialects that don't support "rowcount" adequately.
+ [ticket:1569]
+
- Deprecated or removed:
* 'allow_null_pks' flag on mapper() is deprecated. It does
nothing now and the setting is "on" in all cases.
#self.supports_unicode_statements = True
#self.supports_unicode_binds = True
#self.returns_unicode_strings = True
-
+
+ @property
+ def dialect_description(self):
+ return self.name + "+" + self.driver
+
def initialize(self, connection):
try:
self.server_version_info = self._get_server_version_info(connection)
if update:
mapper = table_to_mapper[table]
clause = sql.and_()
-
+
for col in mapper._pks_by_table[table]:
clause.clauses.append(col == sql.bindparam(col._label, type_=col.type))
rows += c.rowcount
- if c.supports_sane_rowcount() and rows != len(update):
- raise exc.ConcurrentModificationError("Updated rowcount %d does not match number of objects updated %d" % (rows, len(update)))
-
+ if connection.dialect.supports_sane_rowcount:
+ if rows != len(update):
+ raise exc.ConcurrentModificationError(
+ "Updated rowcount %d does not match number of objects updated %d" %
+ (rows, len(update)))
+
+ elif mapper.version_id_col is not None:
+ util.warn("Dialect %s does not support updated rowcount "
+ "- versioning cannot be verified." % c.dialect.dialect_description)
+
if insert:
statement = table.insert()
for state, params, mapper, connection, value_params in insert:
class Foo(_base.ComparableEntity):
pass
+ @testing.emits_warning(r'.*does not support updated rowcount')
@engines.close_open_connections
@testing.resolve_artifact_names
def test_basic(self):
- mapper(Foo, version_table, version_id_col=version_table.c.version_id)
+ mapper(Foo, version_table,
+ version_id_col=version_table.c.version_id)
s1 = create_session(autocommit=False)
f1 = Foo(value='f1')
else:
s1.commit()
+ @engines.close_open_connections
+ @testing.resolve_artifact_names
+ def test_notsane_warning(self):
+ save = testing.db.dialect.supports_sane_rowcount
+ testing.db.dialect.supports_sane_rowcount = False
+ try:
+ mapper(Foo, version_table,
+ version_id_col=version_table.c.version_id)
+
+ s1 = create_session(autocommit=False)
+ f1 = Foo(value='f1')
+ f2 = Foo(value='f2')
+ s1.add_all((f1, f2))
+ s1.commit()
+
+ f1.value='f1rev2'
+ assert_raises(sa.exc.SAWarning, s1.commit)
+ finally:
+ testing.db.dialect.supports_sane_rowcount = save
+
+ @testing.emits_warning(r'.*does not support updated rowcount')
@engines.close_open_connections
@testing.resolve_artifact_names
def test_versioncheck(self):
s1.close()
s1.query(Foo).with_lockmode('read').get(f1s1.id)
+ @testing.emits_warning(r'.*does not support updated rowcount')
@engines.close_open_connections
@testing.resolve_artifact_names
def test_noversioncheck(self):