mirror of
https://github.com/pocoproject/poco.git
synced 2024-12-12 10:13:51 +01:00
fix(ActiveRecord): Error between Poco::ActiveRecord and Poco::Data::PostgreSQL #4450
This commit is contained in:
parent
0818febed3
commit
e428c4b46c
@ -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()",
|
||||
|
@ -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>();
|
||||
|
Loading…
Reference in New Issue
Block a user