PEAR is archived and read-only

This mirror preserves historical PEAR package releases and metadata so existing references remain available.

Home » Database » DB_DataObject » Bug #507

non-native sequences are broken

Details

Submitted2003-12-31 22:46 UTC
Fromieure at debian dot org
Assignedalan_k
StatusClosed
PackageDB_DataObject
PHP Version4.3.3
OSLinux
Roadmaps(Not assigned)

Comments

[2003-12-31 22:46 UTC] ieure at debian dot org

Description:
------------
The implementation of non-native sequences is broken in DB_DataObject 1.4. When trying to use non-native sequences (explicitly set with $object->sequenceKey('id', FALSE)), the primary key is not set in the INSERT query.

The PostgreSQL 'serial' datatype defaults to the next free value from a sequence; inserting a row with a blank primary key increments the sequence for that field.

The upshot is that the DataObject has an id of 107, but the record in the database has an id of 108.

DB_DataObject 1.3 does not exhibit this behavior.

Reproduce code:
---------------
$object->sequenceKey('id', false);
$object->setFrom($values);
$newId = $object->insert();

Expected result:
----------------
$object->id should contain the same value as the 'id' field in the database.

Actual result:
--------------
$object->id contains an incorrect value, which does not reference any row in the database.