zendframework / zend-db

Db component from Zend Framework
BSD 3-Clause "New" or "Revised" License
101 stars 122 forks source link

SequenceFeature - invalid quoting for Postgresql adapter #161

Open xorock opened 8 years ago

xorock commented 8 years ago

I'm using Postgresql schemas (without SET search_path). What I'm trying to achieve is getting getLastGeneratedValue with TableGateway when in transaction. I've added new SequenceFeature('id', 'site.table_id_seq') but this throws PDOException. Generated query is SELECT NEXTVAL('"site.table_id_seq"') and should be SELECT NEXTVAL('"site"."table_id_seq"').

To fix this You should allow arrays as second parameter ( new SequenceFeature('id', ['site', 'table_id_seq')) and change

case 'PostgreSQL':
    $sql = 'SELECT NEXTVAL(\'"' . $this->sequenceName . '"\')';

to

case 'PostgreSQL':
    $sql = 'SELECT NEXTVAL(\'' . $platform->quoteIdentifierChain($this->sequenceName) . '\')';

Same for CURRVAL.

michalbundyra commented 4 years ago

This repository has been closed and moved to laminas/laminas-db; a new issue has been opened at https://github.com/laminas/laminas-db/issues/99.