Skip to content

Commit

Permalink
Merge pull request #269 from nextras/dbs
Browse files Browse the repository at this point in the history
New db versions to test
  • Loading branch information
hrach authored Mar 2, 2025
2 parents d2e107a + 65b9ac9 commit 4358675
Show file tree
Hide file tree
Showing 10 changed files with 84 additions and 54 deletions.
1 change: 1 addition & 0 deletions .github/renovate.json5
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,6 @@
"$schema": "https://docs.renovatebot.com/renovate-schema.json",
"extends": [
"config:recommended",
"schedule:earlyMondays"
],
}
48 changes: 29 additions & 19 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ on:
- v*.*

env:
php-extensions: mbstring, intl, mysqli, pgsql, sqlsrv-5.10.0-beta1, pdo_sqlsrv-5.10.0-beta1
php-extensions: mbstring, intl, mysqli, pgsql, sqlsrv, pdo_sqlsrv
php-extensions-key: v1
php-tools: "composer:v2, pecl"

Expand Down Expand Up @@ -63,37 +63,45 @@ jobs:
runs-on: ubuntu-latest

services:
mysql57:
image: mysql:5.7
# MySQL LTS versions tested (https://endoflife.date/mysql)
mysql80:
image: mysql:8.0
ports:
- 3306:3306
options: --health-cmd="mysqladmin ping -ppass" --health-interval=10s --health-timeout=5s --health-retries=5 -e MYSQL_ROOT_PASSWORD=root -e MYSQL_DATABASE=nextras_dbal_test --entrypoint sh mysql:8 -c "exec docker-entrypoint.sh mysqld --mysql-native-password=ON"
mysql84:
image: mysql:8.4
ports:
- 3307:3306
options: --health-cmd="mysqladmin ping -ppass" --health-interval=10s --health-timeout=5s --health-retries=5 -e MYSQL_ROOT_PASSWORD=root -e MYSQL_DATABASE=nextras_dbal_test --entrypoint sh mysql:8 -c "exec docker-entrypoint.sh mysqld --mysql-native-password=ON"
# Latest 2 MariaDD LTS versions tested (https://endoflife.date/mariadb)
mariadb1011:
image: mariadb:10.11
env:
MYSQL_DATABASE: nextras_dbal_test
MYSQL_ROOT_PASSWORD: root
ports:
- 3306:3306
- 3308:3306
options: >-
--health-cmd "mysqladmin ping -ppass"
--health-interval 10s
--health-start-period 10s
--health-timeout 5s
--health-retries 10
mysql80:
image: mysql:8.0
ports:
- 3307:3306
options: --health-cmd="mysqladmin ping -ppass" --health-interval=10s --health-timeout=5s --health-retries=5 -e MYSQL_ROOT_PASSWORD=root -e MYSQL_DATABASE=nextras_dbal_test --entrypoint sh mysql:8 -c "exec docker-entrypoint.sh mysqld --mysql-native-password=ON"
mariadb105:
image: mariadb:10.5
mariadb1104:
image: mariadb:11.4
env:
MYSQL_DATABASE: nextras_dbal_test
MYSQL_ROOT_PASSWORD: root
ports:
- 3308:3306
- 3309:3306
options: >-
--health-cmd "mysqladmin ping -ppass"
--health-cmd "healthcheck.sh --su-mysql --connect --innodb_initialized"
--health-interval 10s
--health-start-period 10s
--health-timeout 5s
--health-retries 10
# Newest and last supported version (https://endoflife.date/postgresql)
postgres13:
image: postgres:13
env:
Expand All @@ -107,8 +115,8 @@ jobs:
--health-interval 10s
--health-timeout 5s
--health-retries 5
postgres16:
image: postgres:16
postgres17:
image: postgres:17
env:
POSTGRES_USER: postgres
POSTGRES_PASSWORD: postgres
Expand All @@ -120,6 +128,7 @@ jobs:
--health-interval 10s
--health-timeout 5s
--health-retries 5
# Latest only
mssql:
image: mcr.microsoft.com/mssql/server:latest
env:
Expand All @@ -140,14 +149,14 @@ jobs:
uses: actions/checkout@v4

- name: Install Microsoft ODBC
run: |
echo "\n[ODBC]\nPooling=No" > /etc/odbcinst.ini
sudo ACCEPT_EULA=Y apt-get install msodbcsql18 -y
sudo cat /etc/odbcinst.ini
run: sudo ACCEPT_EULA=Y apt-get install msodbcsql18 -y

- name: Create MS SQL Database
run: docker exec -i mssql /opt/mssql-tools18/bin/sqlcmd -C -S localhost -U SA -P 'YourStrong!Passw0rd' -Q 'CREATE DATABASE nextras_dbal_test'

- name: Set up Timezones in MariaDB
run: docker exec $(docker ps -q --filter "ancestor=mariadb:11.4") bash -c "apt-get update && apt-get install -y tzdata && mariadb-tzinfo-to-sql /usr/share/zoneinfo 2>/dev/null | mariadb -u root -proot mysql"

- name: Setup PHP cache environment
id: php-extensions-cache
uses: shivammathur/cache-extensions@v1
Expand All @@ -170,6 +179,7 @@ jobs:
extensions: ${{ env.php-extensions }}
tools: ${{ env.php-tools }}
coverage: pcov
ini-values: "pdo_odbc.connection_pooling=off"

- name: Get composer cache directory
id: composercache
Expand Down
10 changes: 3 additions & 7 deletions tests/cases/integration/connection.sqlserver.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
namespace NextrasTests\Dbal;


use Nextras\Dbal\Drivers\Exception\QueryException;
use Tester\Assert;


Expand All @@ -19,13 +18,10 @@ class ConnectionSqlServerTest extends IntegrationTestCase
{
public function testReconnect()
{
$this->connection->query('create table #temp (val int)');
$this->connection->query('insert into #temp values (1)');
Assert::same(1, $this->connection->query('SELECT * FROM #temp')->fetchField());
$sessionIdBefore = $this->connection->query('SELECT [connection_id] FROM [sys].[dm_exec_connections] where session_id = @@SPID')->fetchField();
$this->connection->reconnect();
Assert::exception(function () {
$this->connection->query('SELECT * FROM #temp');
}, QueryException::class);
$sessionIdAfter = $this->connection->query('SELECT [connection_id] FROM [sys].[dm_exec_connections] where session_id = @@SPID')->fetchField();
Assert::notEqual($sessionIdBefore, $sessionIdAfter);
}


Expand Down
16 changes: 8 additions & 8 deletions tests/cases/integration/datetime.mysql.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -47,9 +47,9 @@ class DateTimeMysqlTest extends IntegrationTestCase

$connection->query('DELETE FROM dates_write');
$connection->query('INSERT INTO dates_write VALUES (%ldt, %dt, %ldt)',
new DateTime('2015-01-01 12:00:00'), // local
new DateTime('2015-01-01 12:00:00 Europe/Kiev'), // 10:00 UTC,
new DateTime('2015-01-01 12:13:14') // local
new DateTime('2015-01-01 12:00:00'), // local
new DateTime('2015-01-01 12:00:00 Europe/Helsinki'), // 10:00 UTC,
new DateTime('2015-01-01 12:13:14') // local
);

$result = $connection->query('SELECT * FROM dates_write');
Expand All @@ -65,7 +65,7 @@ class DateTimeMysqlTest extends IntegrationTestCase
public function testWriteStorageDiffTZ()
{
$connection = $this->createConnection([
'connectionTz' => 'Europe/Kiev',
'connectionTz' => 'Europe/Helsinki',
]);
$this->lockConnection($connection);

Expand Down Expand Up @@ -94,9 +94,9 @@ class DateTimeMysqlTest extends IntegrationTestCase

$connection->query('DELETE FROM dates_write2');
$connection->query('INSERT INTO dates_write2 VALUES (%ldt, %dt, %ldt)',
new \DateTimeImmutable('2015-01-01 12:00:00'), // local
new \DateTimeImmutable('2015-01-01 12:00:00 Europe/Kiev'), // 10:00 UTC
new \DateTimeImmutable('2015-01-01 12:13:14') // local
new \DateTimeImmutable('2015-01-01 12:00:00'), // local
new \DateTimeImmutable('2015-01-01 12:00:00 Europe/Helsinki'), // 10:00 UTC
new \DateTimeImmutable('2015-01-01 12:13:14') // local
);

$result = $connection->query('SELECT * FROM dates_write2');
Expand Down Expand Up @@ -144,7 +144,7 @@ class DateTimeMysqlTest extends IntegrationTestCase
public function testReadStorageDiffTZ()
{
$connection = $this->createConnection([
'connectionTz' => 'Europe/Kiev',
'connectionTz' => 'Europe/Helsinki',
]);
$this->lockConnection($connection);

Expand Down
18 changes: 9 additions & 9 deletions tests/cases/integration/datetime.postgres.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ class DateTimePostgresTest extends IntegrationTestCase

$connection->query('INSERT INTO dates_write VALUES (%ldt, %dt, %ldt)',
new DateTime('2015-01-01 12:00:00'), // local
new DateTime('2015-01-01 12:00:00'), // 11:00 UTC
new DateTime('2015-01-01 12:00:00'), // 11:00 UTC
new DateTime('2015-01-01 00:00:00') // local
);

Expand All @@ -47,9 +47,9 @@ class DateTimePostgresTest extends IntegrationTestCase

$connection->query('DELETE FROM dates_write');
$connection->query('INSERT INTO dates_write VALUES (%ldt, %dt, %ldt)',
new DateTime('2015-01-01 12:00:00'), // local
new DateTime('2015-01-01 12:00:00 Europe/Kiev'), // 10:00 UTC
new DateTime('2015-01-01 12:13:14') // local
new DateTime('2015-01-01 12:00:00'), // local
new DateTime('2015-01-01 12:00:00 Europe/Helsinki'), // 10:00 UTC
new DateTime('2015-01-01 12:13:14') // local
);

$result = $connection->query('SELECT * FROM dates_write');
Expand All @@ -65,7 +65,7 @@ class DateTimePostgresTest extends IntegrationTestCase
public function testWriteStorageDiffTZ()
{
$connection = $this->createConnection([
'connectionTz' => 'Europe/Kiev',
'connectionTz' => 'Europe/Helsinki',
]);
$this->lockConnection($connection);

Expand Down Expand Up @@ -94,9 +94,9 @@ class DateTimePostgresTest extends IntegrationTestCase

$connection->query('DELETE FROM dates_write2');
$connection->query('INSERT INTO dates_write2 VALUES (%ldt, %dt, %ldt)',
new \DateTimeImmutable('2015-01-01 12:00:00'), // 11:00 UTC
new \DateTimeImmutable('2015-01-01 12:00:00 Europe/Kiev'), // 10:00 UTC
new \DateTimeImmutable('2015-01-01 12:13:14') // local
new \DateTimeImmutable('2015-01-01 12:00:00'), // 11:00 UTC
new \DateTimeImmutable('2015-01-01 12:00:00 Europe/Helsinki'), // 10:00 UTC
new \DateTimeImmutable('2015-01-01 12:13:14') // local
);

$result = $connection->query('SELECT * FROM dates_write2');
Expand Down Expand Up @@ -144,7 +144,7 @@ class DateTimePostgresTest extends IntegrationTestCase
public function testReadStorageDiffTZ()
{
$connection = $this->createConnection([
'connectionTz' => 'Europe/Kiev',
'connectionTz' => 'Europe/Helsinki',
]);
$this->lockConnection($connection);

Expand Down
6 changes: 3 additions & 3 deletions tests/cases/integration/datetime.sqlserver.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ class DateTimeSqlServerTest extends IntegrationTestCase
Assert::same('2015-01-01 12:00:00.000', $row->a);

// different timezone than db
date_default_timezone_set('Europe/Kiev');
date_default_timezone_set('Europe/Helsinki');

$result = $connection->query('SELECT * FROM dates_write');
$result->setValueNormalization(false);
Expand Down Expand Up @@ -74,7 +74,7 @@ class DateTimeSqlServerTest extends IntegrationTestCase

$connection->query('DELETE FROM dates');
$connection->query('INSERT INTO dates VALUES (%dt)',
new DateTime('2015-01-01 13:00:00 Europe/Kiev') // 11:00 UTC
new DateTime('2015-01-01 13:00:00 Europe/Helsinki') // 11:00 UTC
);

$result = $connection->query('SELECT * FROM dates');
Expand All @@ -88,7 +88,7 @@ class DateTimeSqlServerTest extends IntegrationTestCase

$connection->query('DELETE FROM dates');
$connection->query('INSERT INTO dates VALUES (%dt)',
new DateTime('2015-01-01 14:00:00 Europe/Kiev') // 12:00 UTC
new DateTime('2015-01-01 14:00:00 Europe/Helsinki') // 12:00 UTC
);

$result = $connection->query('SELECT * FROM dates');
Expand Down
2 changes: 2 additions & 0 deletions tests/cases/integration/platform.mysql.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ class PlatformMysqlTest extends IntegrationTestCase
{
public function testTables()
{
$this->lockConnection($this->connection);
$dbName = $this->connection->getConfig()['database'];
$tables = $this->connection->getPlatform()->getTables();

Expand All @@ -44,6 +45,7 @@ class PlatformMysqlTest extends IntegrationTestCase

public function testColumns()
{
$this->lockConnection($this->connection);
$columns = $this->connection->getPlatform()->getColumns('books');
$columns = array_map(function($table) {
return (array) $table;
Expand Down
3 changes: 3 additions & 0 deletions tests/cases/integration/platform.postgres.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ class PlatformPostgresTest extends IntegrationTestCase
{
public function testTables()
{
$this->lockConnection($this->connection);
$tables = $this->connection->getPlatform()->getTables();

Assert::true(isset($tables["public.books"]));
Expand All @@ -37,6 +38,7 @@ class PlatformPostgresTest extends IntegrationTestCase

public function testColumns()
{
$this->lockConnection($this->connection);
$columns = $this->connection->getPlatform()->getColumns('books');
$columns = \array_map(function ($column) { return (array) $column; }, $columns);

Expand Down Expand Up @@ -191,6 +193,7 @@ class PlatformPostgresTest extends IntegrationTestCase

public function testForeignKeys()
{
$this->lockConnection($this->connection);
$keys = $this->connection->getPlatform()->getForeignKeys('books');
$keys = \array_map(function ($key) { return (array) $key; }, $keys);

Expand Down
2 changes: 2 additions & 0 deletions tests/cases/integration/platform.sqlserver.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ class PlatformSqlServerTest extends IntegrationTestCase
{
public function testTables()
{
$this->lockConnection($this->connection);
$tables = $this->connection->getPlatform()->getTables();

Assert::true(isset($tables["dbo.books"]));
Expand All @@ -37,6 +38,7 @@ class PlatformSqlServerTest extends IntegrationTestCase

public function testColumns()
{
$this->lockConnection($this->connection);
$columns = $this->connection->getPlatform()->getColumns('books');
$columns = \array_map(function ($column) { return (array) $column; }, $columns);

Expand Down
Loading

0 comments on commit 4358675

Please sign in to comment.