I posted this on StackOverflow: We have a MySQL database and we're switching from DB API to SQLAlchemy. > From the documentation, the ResultProxy.rowcount is supposed to report the > number of affected rows by an UPDATE statement. > If I execute this query with SQLAlchemy: > UPDATE table > SET field = > IF(field < 10, 10, field) WHERE id = 1 > It will return a rowcount of 1 if there's a matching row, but for any > value of "field" (even when greater or equal than 10). When I executed this > query with DB API, it returned the correct number of affected rows (0 when > field was greater or equal than 10 and 1 if lower). > That's causing us some troubles because we'll have to first execute a > select query to determine if there was a change or not. Is it a bug in > SQLAlchemy? The documentation clearly states that if should return the > number of affected rows, not the number of matching rows.
I got an answer saying that if CLIENT_FOUND_ROWS is set, the number of affected rows becomes the number of matching rows. I've checked and SQLAlchemy sets this flag. This is clearly in contradiction with the documentation, so I think that it's a bug that should be fixed. -- You received this message because you are subscribed to the Google Groups "sqlalchemy" group. To view this discussion on the web visit https://groups.google.com/d/msg/sqlalchemy/-/rA953M70mu4J. To post to this group, send email to sqlalchemy@googlegroups.com. To unsubscribe from this group, send email to sqlalchemy+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/sqlalchemy?hl=en.