Skip to content
This repository has been archived by the owner on May 16, 2018. It is now read-only.

PgSQL lastInsertId() incorrect in a transaction #40

Open
zfbot opened this issue Apr 5, 2013 · 2 comments
Open

PgSQL lastInsertId() incorrect in a transaction #40

zfbot opened this issue Apr 5, 2013 · 2 comments

Comments

@zfbot
Copy link

zfbot commented Apr 5, 2013

Jira Information

Original Issue:ZF-12484
Issue Type:Bug
Reporter:Vestigal
Created:12/06/12
Assignee:Ralph Schindler
Components:Zend_Db

Description

When one calls lastInsertId() without any parameters inside a transaction that has not yet been committed, an incorrect value is returned.

To reproduce:

$this->getAdapter()->beginTransaction();
$this->insert(); // We assume that the table has a primary key named 'id' that is automatically incremented.
var_dump($this->getAdapter()->lastInsertId()); // Returns false

If one calls lastInsertId() with both parameters, then the correct value is returned. I.E.

var_dump($this->getAdapter()->lastInsertId($this->_name, 'id')); // Prints a number, like 23, which is what we would expect.

I tested this using Postgres, but it could be an issue in other adapters, as well.

@zfbot
Copy link
Author

zfbot commented Apr 5, 2013

This issue was ported from the ZF2 Jira Issue Tracker at
http://framework.zend.com/issues/browse/ZF-12484

Known GitHub users mentioned in the original message or comment:

@vestigal
Copy link

vestigal commented Apr 9, 2013

I was the original filer of this bug, back when it was on Jira.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

2 participants