From abcc290a7c0adf473cf7f0cf3fd69002f268a005 Mon Sep 17 00:00:00 2001 From: Yuri Kuznetsov Date: Fri, 3 Mar 2023 15:09:00 +0200 Subject: [PATCH] pg encoding --- application/Espo/ORM/PDO/PostgresqlPDOFactory.php | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/application/Espo/ORM/PDO/PostgresqlPDOFactory.php b/application/Espo/ORM/PDO/PostgresqlPDOFactory.php index 887991590a..12bbd311ac 100644 --- a/application/Espo/ORM/PDO/PostgresqlPDOFactory.php +++ b/application/Espo/ORM/PDO/PostgresqlPDOFactory.php @@ -35,6 +35,8 @@ use RuntimeException; class PostgresqlPDOFactory implements PDOFactory { + private const DEFAULT_CHARSET = 'utf8'; + public function create(DatabaseParams $databaseParams): PDO { $platform = strtolower($databaseParams->getPlatform() ?? ''); @@ -42,7 +44,7 @@ class PostgresqlPDOFactory implements PDOFactory $host = $databaseParams->getHost(); $port = $databaseParams->getPort(); $dbname = $databaseParams->getName(); - //$charset = $databaseParams->getCharset(); + $charset = $databaseParams->getCharset() ?? self::DEFAULT_CHARSET; $username = $databaseParams->getUsername(); $password = $databaseParams->getPassword(); @@ -64,9 +66,7 @@ class PostgresqlPDOFactory implements PDOFactory $dsn .= ';' . 'dbname=' . $dbname; } - /*if ($charset) { - $dsn .= ';' . 'options=' . "'--client_encoding={$charset}'"; - }*/ + $dsn .= ';' . 'options=' . "'--client_encoding={$charset}'"; $options = Options::getOptionsFromDatabaseParams($databaseParams);