zendframework/zend-db

SequenceFeature - invalid quoting for Postgresql adapter

Opened this issue · 1 comments

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.

This repository has been closed and moved to laminas/laminas-db; a new issue has been opened at laminas/laminas-db#99.