Issue 1:
Migrated issue, originally created by NotTheEvilOne (@NotTheEvilOne)

Hi,

the "autoflush" feature triggers an error in SQLAlchemy 0.9.6.

File "/opt/pas/src/dNG/pas/data/upnp/resources/mp_entry.py", line 588, in init_cds_id
.first()
File "/usr/lib/python3.4/site-packages/sqlalchemy/orm/query.py", line 2334, in first
ret = list(self[0:1])
File "/usr/lib/python3.4/site-packages/sqlalchemy/orm/query.py", line 2201, in __getitem__
return list(res)
File "/usr/lib/python3.4/site-packages/sqlalchemy/orm/query.py", line 2404, in __iter__
self.session._autoflush()
File "/usr/lib/python3.4/site-packages/sqlalchemy/orm/session.py", line 1188, in _autoflush
self.flush()
File "/usr/lib/python3.4/site-packages/sqlalchemy/orm/session.py", line 1907, in flush
self._flush(objects)
File "/usr/lib/python3.4/site-packages/sqlalchemy/orm/session.py", line 2025, in _flush
transaction.rollback(_capture_exception=True)
File "/usr/lib/python3.4/site-packages/sqlalchemy/util/langhelpers.py", line 57, in __exit__
compat.reraise(exc_type, exc_value, exc_tb)
File "/usr/lib/python3.4/site-packages/sqlalchemy/util/compat.py", line 172, in reraise
raise value
File "/usr/lib/python3.4/site-packages/sqlalchemy/orm/session.py", line 1989, in _flush
flush_context.execute()
File "/usr/lib/python3.4/site-packages/sqlalchemy/orm/unitofwork.py", line 350, in execute
postsort_actions = self._generate_actions()
File "/usr/lib/python3.4/site-packages/sqlalchemy/orm/unitofwork.py", line 324, in _generate_actions
for rec in cycles
File "/usr/lib/python3.4/site-packages/sqlalchemy/orm/unitofwork.py", line 324, in <genexpr>
for rec in cycles
File "/usr/lib/python3.4/site-packages/sqlalchemy/orm/unitofwork.py", line 541, in per_state_flush_actions
dep.per_state_flush_actions(uow, states_for_prop, False)
File "/usr/lib/python3.4/site-packages/sqlalchemy/orm/dependency.py", line 166, in per_state_flush_actions
else attributes.PASSIVE_NO_INITIALIZE)
TypeError: get_all_pending() takes 3 positional arguments but 4 were given

I think it's related to commit 69dbcdd which in turn is related to #3060 as far as I understand.

Best regards

Tobias

Issue 2:
Migrated issue, originally created by Anonymous

With such scheme:

exportables = sa.Table(
't_exportable', meta,
sa.Column('object_id', OracleNumber, primary_key=True),
sa.Column('type', sa.String(20), primary_key=True),
sa.Column('state', sa.Integer),
)

and class hierarchy:

class Exportable(Base):
__table__ = exportables

__mapper_args__ = {
'polymorphic_on': exportables.c.type,
}

class ExportableTEST(Exportable):
__mapper_args__ = {
'polymorphic_identity': 'TEST',
}

When updating attributes of ExportableTEST object error "''ConcurrentModificationError: Updated rowcount 0 does not match number of objects updated 1''" acquired. Because of primary key is not passed to update query:

''INFO:sqlalchemy.engine.base.Engine.0x...fdac:UPDATE t_exportable SET state=:state WHERE t_exportable.opcode = :t_exportable_opcode AND t_exportable.object_id = :t_exportable_object_id AND t_exportable.type = :t_exportable_type

INFO:sqlalchemy.engine.base.Engine.0x...fdac:{'t_exportable_object_id': Decimal("8756"), 'state': 3, 't_exportable_type': None, 't_exportable_opcode': 18}''

Attachments: mapper.diff