From b6834b16564b238530aa3313f8e3d5c953637ba8 Mon Sep 17 00:00:00 2001 From: Thorsten Reiter Date: Mon, 18 Nov 2024 10:38:12 +0100 Subject: [PATCH] Added PostgresqlGateway --- .../DatabasePlatform/FallbackGateway.php | 22 +++++++ .../DatabasePlatform/PostgresqlGateway.php | 58 +++++++++++++++++++ .../DatabasePlatform/SqliteGateway.php | 22 +++++++ .../Legacy/SharedGateway/Gateway.php | 5 ++ 4 files changed, 107 insertions(+) create mode 100644 src/lib/Persistence/Legacy/SharedGateway/DatabasePlatform/PostgresqlGateway.php diff --git a/src/lib/Persistence/Legacy/SharedGateway/DatabasePlatform/FallbackGateway.php b/src/lib/Persistence/Legacy/SharedGateway/DatabasePlatform/FallbackGateway.php index 7a7a483c54..02f5b1972a 100644 --- a/src/lib/Persistence/Legacy/SharedGateway/DatabasePlatform/FallbackGateway.php +++ b/src/lib/Persistence/Legacy/SharedGateway/DatabasePlatform/FallbackGateway.php @@ -29,6 +29,28 @@ public function getColumnNextIntegerValue( return null; } + /** + * Return a language sub select query for setName. + * + * The query generates the proper language mask at the runtime of the INSERT/UPDATE query + * generated by setName. + * + * @see setName + */ + public function getSetNameLanguageMaskSubQuery(): string + { + return << 0 ) + THEN (:language_id | 1) + ELSE :language_id + END + FROM ezcontentobject + WHERE id = :content_id) + SQL; + } + public function getLastInsertedId(string $sequenceName): int { return (int)$this->connection->lastInsertId($sequenceName); diff --git a/src/lib/Persistence/Legacy/SharedGateway/DatabasePlatform/PostgresqlGateway.php b/src/lib/Persistence/Legacy/SharedGateway/DatabasePlatform/PostgresqlGateway.php new file mode 100644 index 0000000000..3d14c4c879 --- /dev/null +++ b/src/lib/Persistence/Legacy/SharedGateway/DatabasePlatform/PostgresqlGateway.php @@ -0,0 +1,58 @@ +connection = $connection; + } + + public function getColumnNextIntegerValue( + string $tableName, + string $columnName, + string $sequenceName + ): ?int { + return null; + } + + public function getLastInsertedId(string $sequenceName): int + { + return (int)$this->connection->lastInsertId($sequenceName); + } + + /** + * Return a language sub select query for setName. + * + * The query generates the proper language mask at the runtime of the INSERT/UPDATE query + * generated by setName. + * + * @see setName + */ + public function getSetNameLanguageMaskSubQuery(): string + { + return << 0 ) + THEN (cast(:language_id as BIGINT) | 1) + ELSE :language_id + END + FROM ezcontentobject + WHERE id = :content_id) + SQL; + } +} diff --git a/src/lib/Persistence/Legacy/SharedGateway/DatabasePlatform/SqliteGateway.php b/src/lib/Persistence/Legacy/SharedGateway/DatabasePlatform/SqliteGateway.php index b92fa7ea03..0883fc7a76 100644 --- a/src/lib/Persistence/Legacy/SharedGateway/DatabasePlatform/SqliteGateway.php +++ b/src/lib/Persistence/Legacy/SharedGateway/DatabasePlatform/SqliteGateway.php @@ -49,6 +49,28 @@ public function getLastInsertedId(string $sequenceName): int return $this->lastInsertedIds[$sequenceName]; } + + /** + * Return a language sub select query for setName. + * + * The query generates the proper language mask at the runtime of the INSERT/UPDATE query + * generated by setName. + * + * @see setName + */ + public function getSetNameLanguageMaskSubQuery(): string + { + return << 0 ) + THEN (:language_id | 1) + ELSE :language_id + END + FROM ezcontentobject + WHERE id = :content_id) + SQL; + } } class_alias(SqliteGateway::class, 'eZ\Publish\Core\Persistence\Legacy\SharedGateway\DatabasePlatform\SqliteGateway'); diff --git a/src/lib/Persistence/Legacy/SharedGateway/Gateway.php b/src/lib/Persistence/Legacy/SharedGateway/Gateway.php index 9b947b146c..eb674d3de3 100644 --- a/src/lib/Persistence/Legacy/SharedGateway/Gateway.php +++ b/src/lib/Persistence/Legacy/SharedGateway/Gateway.php @@ -41,6 +41,11 @@ public function getColumnNextIntegerValue( * It returns integer as all the IDs in the Ibexa Legacy Storage are (big)integers */ public function getLastInsertedId(string $sequenceName): int; + + /** + * Return a language sub select query for setName. + */ + public function getSetNameLanguageMaskSubQuery(): string; } class_alias(Gateway::class, 'eZ\Publish\Core\Persistence\Legacy\SharedGateway\Gateway');