fix(ActiveRecord): Error between Poco::ActiveRecord and Poco::Data::PostgreSQL #4450

This commit is contained in:
Günter Obiltschnig 2024-04-03 07:01:34 +02:00
parent 0818febed3
commit e428c4b46c
2 changed files with 9 additions and 5 deletions

View File

@ -240,23 +240,24 @@ template <typename IDType>
IDType ActiveRecord<IDType>::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()",

View File

@ -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<PostgresStatementPlaceholderProvider>();
else
return std::make_unique<DefaultStatementPlaceholderProvider>();