On 7/11/14, 5:07 PM, Staszek wrote: > On 2014-02-01 00:09, Michael Bayer wrote: >> On Jan 31, 2014, at 5:24 PM, lars van gemerden <[email protected] >> <mailto:[email protected]>> wrote: >> >>> Hi, all >>> >>> I am running into these 2 errors and have run out of ideas what to do >>> about it (also because i don't what they mean); They seem to happen in >>> exactly the same circumstances. >>> >>> mapper, table, update) >>> File "build\bdist.win32\egg\sqlalchemy\orm\persistence.py", line >>> 514, in _emit_update_statements >>> (table.description, len(update), rows)) >>> StaleDataError: UPDATE statement on table 'Company' expected to update >>> 1 row(s); 0 were matched. >> this means an object was meant to be UPDATEed via the ORM, however the >> row which is the target of the UPDATE is missing. Either the primary >> key of this row changed somehow, or the row was deleted, *or* the row is >> not visible to your transaction (this seems to be your case). > I am running into something very similar: > > StaleDataError: UPDATE statement on table 'buildings' expected to update > 1 row(s); 0 were matched. > > However this case is very simple, just a single row in a table, and it > looks to get selected just before the update (in the same transaction). > Nothing is being deleted. > > The update: > > UPDATE buildings SET glatitude=%s, glongitude=%s WHERE buildings.id = %s > > The columns: > > id = Column(BigInteger, autoincrement=True, primary_key=True) > glatitude = Column(Numeric(precision=11, scale=8)) > glongitude = Column(Numeric(precision=11, scale=8)) > > What's interesting is that the error occurs only if glatitude and > glongitude are being updated to the same values that are already in the > database (i.e.: no real update). > When the old values are NULL or otherwise different than the new values, > everything works fine! > > Is this a bug? It's unlikely to be a SQLAlchemy bug, but questions to be answered include: Can you produce a self-contained test case? Have you tried SQLAlchemy 0.9.6 rather than 0.9.1? Also what backend is this, MySQL? MySQL has had some bugs where the rowcount is not reported correctly.
-- You received this message because you are subscribed to the Google Groups "sqlalchemy" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. To post to this group, send email to [email protected]. Visit this group at http://groups.google.com/group/sqlalchemy. For more options, visit https://groups.google.com/d/optout.
