correctly documented API for mysql FOUND_ROWS
Issue #3146
resolved
Hi,
The mysql connector sets by default the FOUND_ROWS bit in the client_flag set on each connection with the server. The documentation is explicit about this (good): http://docs.sqlalchemy.org/en/rel_0_9/dialects/mysql.html#rowcount-support
However, the documentation also says that it is possible to override this setting through the client_flag url argument. While it is indeed possible to set manually this client_flag argument, the FOUND_ROWS bit is set unconditionally in dialects/mysql/mysqlconnector.py
Hence, the attached patch (generated against git master) to allow callers who know what they are doing to override this default behavior in sqlalchemy
Comments (7)
-
repo owner -
repo owner - changed title to working / correctly documented API for mysql FOUND_ROWS
- changed milestone to 1.0
-
repo owner - changed status to resolved
- mention that FOUND_ROWS is hardcoded; fixes
#3146
→ <<cset 9f66e75ea71f>>
-
repo owner - mention that FOUND_ROWS is hardcoded; fixes
#3146
→ <<cset a16ee423e452>>
- mention that FOUND_ROWS is hardcoded; fixes
-
repo owner - mention that FOUND_ROWS is hardcoded; fixes
#3146
→ <<cset c149e020cbeb>>
- mention that FOUND_ROWS is hardcoded; fixes
-
repo owner -
repo owner - changed title to correctly documented API for mysql FOUND_ROWS
- changed milestone to 0.9.8
- changed component to documentation
- Log in to comment
I'd rather just change the docs to state that this is not an option. the FOUND_ROWS flag has no point in being changed IMHO.
also, both mysqldb and mysqlconnector have a try/except around the whole operation, in the case of mysqldb this is probably due to very ancient versions of mysqldb and in the case of mysqlconnector I dont think there is any valid case for an except: there. The try/except should be removed.
For the case where you really want to be able to affect this, I'd prefer an explicit option
create_engine(..., count_matched_rows=True)
that works equally for mysqldb, mysqlconnector, oursql, and the others (or raises a NotImplementedError for a DBAPI that doesn't provide for it). I'd need a pull request with unit tests for this.