Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

build with PHP 8.2 #207

Merged
merged 2 commits into from
Apr 10, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ jobs:

strategy:
matrix:
php-version: [ '8.1' ]
php-version: [ '8.1', '8.2' ]

steps:
- name: Checkout
Expand Down Expand Up @@ -58,7 +58,7 @@ jobs:
strategy:
fail-fast: false
matrix:
php-version: [ '8.1' ]
php-version: [ '8.1', '8.2' ]

runs-on: ubuntu-latest

Expand Down
2 changes: 2 additions & 0 deletions src/Drivers/PdoPgsql/PdoPgsqlDriver.php
Original file line number Diff line number Diff line change
Expand Up @@ -158,6 +158,8 @@ protected function processInitialSettings(array $params): void
$params['connectionTz'] = date('P');
}

$this->loggedQuery("SET intervalstyle = 'iso_8601'");

$this->connectionTz = new DateTimeZone($params['connectionTz']);
if (str_contains($this->connectionTz->getName(), ':')) {
$this->loggedQuery('SET TIME ZONE INTERVAL ' . $this->convertStringToSql($this->connectionTz->getName()) . ' HOUR TO MINUTE');
Expand Down
3 changes: 1 addition & 2 deletions src/Drivers/PdoPgsql/PdoPgsqlResultNormalizerFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -53,8 +53,7 @@ public function __construct()

$this->intervalNormalizer = static function($value): ?DateInterval {
if ($value === null) return null;
$interval = DateInterval::createFromDateString($value);
return $interval !== false ? $interval : null;
return new DateInterval($value);
};

$this->varBitNormalizer = static function($value) {
Expand Down
1 change: 1 addition & 0 deletions src/Drivers/Pgsql/PgsqlDriver.php
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,7 @@ public function connect(array $params, ILogger $logger): void

$this->resultNormalizationFactory = new PgsqlResultNormalizerFactory();

$this->loggedQuery("SET intervalstyle = 'iso_8601'");
$this->connectionTz = new DateTimeZone($params['connectionTz']);
if (str_contains($this->connectionTz->getName(), ':')) {
$this->loggedQuery('SET TIME ZONE INTERVAL ' . pg_escape_literal($connection, $this->connectionTz->getName()) . ' HOUR TO MINUTE');
Expand Down
3 changes: 1 addition & 2 deletions src/Drivers/Pgsql/PgsqlResultNormalizerFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -60,8 +60,7 @@ public function __construct()

$this->intervalNormalizer = static function ($value): ?DateInterval {
if ($value === null) return null;
$interval = DateInterval::createFromDateString($value);
return $interval !== false ? $interval : null;
return new DateInterval($value);
};

$this->varBitNormalizer = static function ($value) {
Expand Down
5 changes: 3 additions & 2 deletions tests/cases/integration/types.postgres.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ class TypesPostgresTest extends IntegrationTestCase
$result = $this->connection->query("
SELECT
-- driver specific
'1 day 01:00:00'::interval,
'1 day 1 hour'::interval,
'0100'::bit(4),
'100'::varbit,
'YES'::bool,
Expand All @@ -42,7 +42,8 @@ class TypesPostgresTest extends IntegrationTestCase
");

$row = $result->fetch();
Assert::equal(DateInterval::createFromDateString('1 day 01:00:00'), $row->interval);
Assert::equal(1, $row->interval->d);
Assert::equal(1, $row->interval->h);
Assert::same(4, $row->bit);
Assert::same(4, $row->varbit);
Assert::same(true, $row->bool);
Expand Down