Skip to content

Commit

Permalink
Add postgresql 10 compatibility to dbal
Browse files Browse the repository at this point in the history
Use this before 2.6 branch will be patched doctrine#2893
  • Loading branch information
rishat.girfanov committed Feb 20, 2018
1 parent 9315e61 commit 5bebd9c
Showing 1 changed file with 10 additions and 5 deletions.
15 changes: 10 additions & 5 deletions lib/Doctrine/DBAL/Schema/PostgreSqlSchemaManager.php
Original file line number Diff line number Diff line change
Expand Up @@ -283,14 +283,19 @@ protected function getPortableNamespaceDefinition(array $namespace)
*/
protected function _getPortableSequenceDefinition($sequence)
{
if ($sequence['schemaname'] != 'public') {
$sequenceName = $sequence['schemaname'] . "." . $sequence['relname'];
$version = (float)$this->_conn->getWrappedConnection()->getServerVersion();

if ($version >= 10) {
$data = $this->_conn->fetchAll('SELECT min_value, increment_by FROM pg_sequences WHERE schemaname = ' . $this->_conn->quote($sequence['schemaname']) . ' AND sequencename = ' . $this->_conn->quote($sequence['relname']));
} else {
$sequenceName = $sequence['relname'];
if ($sequence['schemaname'] !== 'public') {
$sequenceName = $sequence['schemaname'] . "." . $sequence['relname'];
} else {
$sequenceName = $sequence['relname'];
}
$data = $this->_conn->fetchAll('SELECT min_value, increment_by FROM ' . $this->_platform->quoteIdentifier($sequenceName));
}

$data = $this->_conn->fetchAll('SELECT min_value, increment_by FROM ' . $this->_platform->quoteIdentifier($sequenceName));

return new Sequence($sequenceName, $data[0]['increment_by'], $data[0]['min_value']);
}

Expand Down

0 comments on commit 5bebd9c

Please sign in to comment.