Skip to content

Commit

Permalink
fix(ActiveRecord): Error between Poco::ActiveRecord and Poco::Data::P…
Browse files Browse the repository at this point in the history
…ostgreSQL #4450
  • Loading branch information
obiltschnig committed Apr 3, 2024
1 parent 0818feb commit e428c4b
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 5 deletions.
9 changes: 5 additions & 4 deletions ActiveRecord/include/Poco/ActiveRecord/ActiveRecord.h
Original file line number Diff line number Diff line change
Expand Up @@ -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()",
Expand Down
5 changes: 4 additions & 1 deletion ActiveRecord/src/Context.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,9 @@
#include "Poco/ActiveRecord/Context.h"


using namespace std::string_literals;


namespace Poco {
namespace ActiveRecord {

Expand All @@ -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>();
Expand Down

0 comments on commit e428c4b

Please sign in to comment.