diff --git a/app/config/config.yml b/app/config/config.yml index 08da4f8f8..04d757c1f 100644 --- a/app/config/config.yml +++ b/app/config/config.yml @@ -47,6 +47,7 @@ twig: doctrine: dbal: driver: "%database_driver%" + driver_class: "%database_driver_class%" host: "%database_host%" port: "%database_port%" dbname: "%database_name%" diff --git a/app/config/config_test.yml b/app/config/config_test.yml index c620c3599..fc067ff46 100644 --- a/app/config/config_test.yml +++ b/app/config/config_test.yml @@ -23,6 +23,7 @@ swiftmailer: doctrine: dbal: driver: "%test_database_driver%" + driver_class: "%test_database_driver_class%" host: "%test_database_host%" port: "%test_database_port%" dbname: "%test_database_name%" diff --git a/app/config/parameters.yml.dist b/app/config/parameters.yml.dist index b5b97950c..6b0cb8e84 100644 --- a/app/config/parameters.yml.dist +++ b/app/config/parameters.yml.dist @@ -11,6 +11,8 @@ parameters: # database_password: %env.database_password% database_driver: pdo_mysql + database_driver_class: ~ + # database_driver_class: Wallabag\CoreBundle\Doctrine\DBAL\Driver\CustomPostgreSQLDriver database_host: 127.0.0.1 database_port: ~ database_name: wallabag diff --git a/app/config/tests/parameters_test.mysql.yml b/app/config/tests/parameters_test.mysql.yml index 36b227fbc..0b7b82eb9 100644 --- a/app/config/tests/parameters_test.mysql.yml +++ b/app/config/tests/parameters_test.mysql.yml @@ -1,5 +1,6 @@ parameters: test_database_driver: pdo_mysql + test_database_driver_class: ~ test_database_host: localhost test_database_port: 3306 test_database_name: wallabag_test diff --git a/app/config/tests/parameters_test.pgsql.yml b/app/config/tests/parameters_test.pgsql.yml index 60f51df6d..ea249324e 100644 --- a/app/config/tests/parameters_test.pgsql.yml +++ b/app/config/tests/parameters_test.pgsql.yml @@ -1,5 +1,6 @@ parameters: test_database_driver: pdo_pgsql + test_database_driver_class: Wallabag\CoreBundle\Doctrine\DBAL\Driver\CustomPostgreSQLDriver test_database_host: localhost test_database_port: test_database_name: wallabag_test diff --git a/app/config/tests/parameters_test.sqlite.yml b/app/config/tests/parameters_test.sqlite.yml index 2b92d579f..64cd984b9 100644 --- a/app/config/tests/parameters_test.sqlite.yml +++ b/app/config/tests/parameters_test.sqlite.yml @@ -1,5 +1,6 @@ parameters: test_database_driver: pdo_sqlite + test_database_driver_class: ~ test_database_host: localhost test_database_port: test_database_name: ~ diff --git a/src/Wallabag/CoreBundle/Doctrine/DBAL/Driver/CustomPostgreSQLDriver.php b/src/Wallabag/CoreBundle/Doctrine/DBAL/Driver/CustomPostgreSQLDriver.php new file mode 100644 index 000000000..eb5b203fa --- /dev/null +++ b/src/Wallabag/CoreBundle/Doctrine/DBAL/Driver/CustomPostgreSQLDriver.php @@ -0,0 +1,25 @@ +_platform->quoteIdentifier($sequenceName); + + // the `method_exists` is only to avoid test to fail: + // DAMA\DoctrineTestBundle\Doctrine\DBAL\StaticConnection doesn't support the `getServerVersion` + if (method_exists($this->_conn->getWrappedConnection(), 'getServerVersion') && (float) ($this->_conn->getWrappedConnection()->getServerVersion()) >= 10) { + $query = "SELECT min_value, increment_by FROM pg_sequences WHERE schemaname = 'public' AND sequencename = " . $this->_conn->quote($sequenceName); + } + + $data = $this->_conn->fetchAll($query); + + return new Sequence($sequenceName, $data[0]['increment_by'], $data[0]['min_value']); + } +}