You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I believe PostgreSQL support is possible by changing the DatabaseStore->writeINSERT statement to use ON CONFLICT instead of ON DUPLICATE. Take this subclass of DatabaseStore for example:
useSilverStripe\Core\ClassInfo;
useSilverStripe\Core\Convert;
useSilverStripe\HybridSessions\Store\DatabaseStore;
useSilverStripe\ORM\DB;
useSilverStripe\PostgreSQL\PostgreSQLDatabase;
class PostgreSQLDatabaseStore extends DatabaseStore
{
protectedfunctionisDatabaseReady()
{
// Such as during setup of testsession prior to DB connection.if (!DB::is_active()) {
returnfalse;
}
// If we have a DB of the wrong type then complainif (!(DB::get_conn() instanceof PostgreSQLDatabase)) {
thrownewException('PostgreSQLDatabaseStore currently only works with PostgreSQL databases');
}
// Prevent freakout during dev/buildreturn ClassInfo::hasTable('HybridSessionDataObject');
}
publicfunctionwrite($session_id, $session_data)
{
if (!$this->isDatabaseReady()) {
returnfalse;
}
$expiry = $this->getNow() + $this->getLifetime();
DB::query($str = sprintf(
'INSERT INTO "HybridSessionDataObject" ("SessionID", "Expiry", "Data") VALUES (\'%1$s\', %2$u, \'%3$s\') ON CONFLICT ("SessionID") DO UPDATE SET "Expiry" = %2$u, "Data" = \'%3$s\'',
Convert::raw2sql($session_id),
$expiry,
Convert::raw2sql(static::binaryDataJsonEncode($session_data))
));
returntrue;
}
}
The text was updated successfully, but these errors were encountered:
I believe PostgreSQL support is possible by changing the
DatabaseStore->write
INSERT
statement to useON CONFLICT
instead ofON DUPLICATE
. Take this subclass ofDatabaseStore
for example:The text was updated successfully, but these errors were encountered: