diff --git a/ActiveRecord/include/Poco/ActiveRecord/ActiveRecord.h b/ActiveRecord/include/Poco/ActiveRecord/ActiveRecord.h index c8d2860f7..be932c572 100644 --- a/ActiveRecord/include/Poco/ActiveRecord/ActiveRecord.h +++ b/ActiveRecord/include/Poco/ActiveRecord/ActiveRecord.h @@ -240,23 +240,24 @@ template IDType ActiveRecord::lastInsertID(Poco::Data::Session& session) { using namespace Poco::Data::Keywords; + using namespace std::string_literals; IDType id; - if (session.connector() == "sqlite") + if (Poco::icompare(session.connector(), "sqlite"s) == 0) { session << "SELECT last_insert_rowid()", into(id), now; } - else if (session.connector() == "PostgreSQL") + else if (Poco::icompare(session.connector(), "postgresql"s) == 0) { session - << "SELECT currval('id_seq')", + << "SELECT lastval()", into(id), now; } - else if (session.connector() == "MySQL") + else if (Poco::icompare(session.connector(), "mysql"s) == 0) { session << "SELECT LAST_INSERT_ID()", diff --git a/ActiveRecord/src/Context.cpp b/ActiveRecord/src/Context.cpp index 499ba090e..d3231a337 100644 --- a/ActiveRecord/src/Context.cpp +++ b/ActiveRecord/src/Context.cpp @@ -15,6 +15,9 @@ #include "Poco/ActiveRecord/Context.h" +using namespace std::string_literals; + + namespace Poco { namespace ActiveRecord { @@ -33,7 +36,7 @@ Context::Context(const std::string& connector, const std::string& connectionStri StatementPlaceholderProvider::Ptr Context::statementPlaceholderProvider() const { - if (_session.connector() == "postgresql") + if (Poco::icompare(_session.connector(), "postgresql"s) == 0) return std::make_unique(); else return std::make_unique();