if not (params or value_params):
continue
- pk_params = {}
- for col in pks:
- propkey = mapper._columntoproperty[col].key
- history = state.manager[propkey].impl.get_history(
- state, state_dict, attributes.PASSIVE_OFF)
-
- if history.added:
- if not history.deleted or \
- ("pk_cascaded", state, col) in \
- uowtransaction.attributes:
- pk_params[col._label] = history.added[0]
- params.pop(col.key, None)
+ if bulk:
+ pk_params = dict(
+ (propkey_to_col[propkey]._label, state_dict.get(propkey))
+ for propkey in
+ set(propkey_to_col).
+ intersection(mapper._pk_keys_by_table[table])
+ )
+ else:
+ pk_params = {}
+ for col in pks:
+ propkey = mapper._columntoproperty[col].key
+
+ history = state.manager[propkey].impl.get_history(
+ state, state_dict, attributes.PASSIVE_OFF)
+
+ if history.added:
+ if not history.deleted or \
+ ("pk_cascaded", state, col) in \
+ uowtransaction.attributes:
+ pk_params[col._label] = history.added[0]
+ params.pop(col.key, None)
+ else:
+ # else, use the old value to locate the row
+ pk_params[col._label] = history.deleted[0]
+ params[col.key] = history.added[0]
else:
- # else, use the old value to locate the row
- pk_params[col._label] = history.deleted[0]
- params[col.key] = history.added[0]
- else:
- pk_params[col._label] = history.unchanged[0]
- if pk_params[col._label] is None:
- raise orm_exc.FlushError(
- "Can't update table %s using NULL for primary "
- "key value on column %s" % (table, col))
+ pk_params[col._label] = history.unchanged[0]
++ if pk_params[col._label] is None:
++ raise orm_exc.FlushError(
++ "Can't update table %s using NULL for primary "
++ "key value on column %s" % (table, col))
if params or value_params:
- if None in pk_params.values():
- raise orm_exc.FlushError(
- "Can't update table using NULL for primary "
- "key value")
params.update(pk_params)
yield (
state, state_dict, params, mapper,