Home » Database » DB_DataObject » Bug #507
non-native sequences are broken
Details
| Submitted | 2003-12-31 22:46 UTC |
|---|---|
| From | ieure at debian dot org |
| Assigned | alan_k |
| Status | Closed |
| Package | DB_DataObject |
| PHP Version | 4.3.3 |
| OS | Linux |
| 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.