From a559fc0b0cb8e3a4de91680773a8f4fea2c9a3d3 Mon Sep 17 00:00:00 2001 From: Boris Kolpackov Date: Fri, 30 Jul 2010 13:26:36 +0200 Subject: Pass CLIENT_FOUND_ROWS to connect --- odb/mysql/connection.cxx | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) (limited to 'odb/mysql/connection.cxx') diff --git a/odb/mysql/connection.cxx b/odb/mysql/connection.cxx index 2e42b9e..27e3067 100644 --- a/odb/mysql/connection.cxx +++ b/odb/mysql/connection.cxx @@ -20,6 +20,11 @@ namespace odb if (mysql_init (handle_) == 0) throw std::bad_alloc (); + // Force the CLIENT_FOUND_ROWS flag so that UPDATE returns the + // number of found rows, not the number of changed rows. This + // is necessary to distinguish between the object-not-persistent + // and nothing-changed conditions. + // if (mysql_real_connect (handle_, db.host (), db.user (), @@ -27,7 +32,7 @@ namespace odb db.db (), db.port (), db.socket (), - db.client_flags ()) == 0) + db.client_flags () | CLIENT_FOUND_ROWS) == 0) { database_exception e (handle_); mysql_close (handle_); -- cgit v1.1