Mike Conley wrote:
> I am getting this error on a session.flush().
>
> sqlalchemy.orm.exc.ConcurrentModificationError: Updated rowcount 0
> does
> not match number of objects updated 1
>
> and can't figure out where to start looking.
it means an UPDATE was issued towards updating the values of a particular
persistent mapped instance, and that the primary key represented by this
instance did not exist in the database at the time the UPDATE was issued,
so no rows matched the WHERE clause.
Since your operation is a "copy", in theory there should only be INSERTs
and not UPDATEs. So at the point of your flush(), session.dirty should
be empty, everything pending would be in
session.new. So that's one
place to look. The other is in SQL logging, you'd see an UPDATE statement
immediately before the exception throw which should indicate exactly what
type of object is targeted as well as what the expected primary key value
of that object is.