Package home | Report new bug | New search | Development Roadmap Status: Open | Feedback | All | Closed Since Version 1.11.5

Bug #605 when sequence_$table used insert returns 1
Submitted: 2004-01-21 19:41 UTC
From: fredrick dot leitz at sjrb dot ca Assigned:
Status: No Feedback Package: DB_DataObject
PHP Version: 4.3.4 OS: FreeBSD 5.2
Roadmaps: (Not assigned)    

 [2004-01-21 19:41 UTC] fredrick dot leitz at sjrb dot ca
Description: ------------ When I enable sequence_response in my ini file insert() always returns one. Reproduce code: --------------- $response = DB_DataObject::factory("response"); $response->account = $_SESSION['LIB_QUESTION_ACCOUNT']; $response->employee = $_SESSION['LIB_QUESTION_EMPLOYEE']; $responseid = $response->insert(); echo "SEQUENCE: $responseid"; Expected result: ---------------- I expect the value returned to be the value inserted into the database. Actual result: -------------- Debug info below.... With out definining sequence_response DB Error: unknown error SELECT NEXTVAL('response_seq') [nativecode=ERROR: relation "response_seq" does not exist ] dataobjects_response: QUERY: INSERT INTO response (response_id , employee , account ) VALUES ( 1 , 0234 , 01000000000 ) DB Error: unknown error INSERT INTO response (response_id , employee , account ) VALUES ( 1 , 0234 , 01000000000 ) [nativecode=ERROR: duplicate key violates unique constraint "response_pkey" ] When defining sequence_response [DB_DataObject] .... sequence_response = response_response_id_seq dataobjects_response: QUERY: INSERT INTO response (employee , account ) VALUES ( 0234 , 01000000000 ) dataobjects_response: query: QUERY DONE IN 0.467092990875 seconds dataobjects_response: 1: Clearing Cache for dataobjects_response SEQUENCE: 1


 [2004-01-21 19:44 UTC] fredrick dot leitz at sjrb dot ca
Oh, also when postgres creates a table the default naming convention for sequences is table_name_column_name_seq so... CREATE TABLE "response" ( response_id SERIAL ); produces a sequence response_response_id_seq in PGSQL > 7.3 I don't know how hard it is to have DataObject generate the same default sequence for PGSQL
 [2004-01-22 02:52 UTC] alan_k
This bug has been fixed in CVS. In case this was a documentation problem, the fix will show up at the end of next Sunday (CET) on In case this was a website problem, the change will show up on the website in short time. Thank you for the report, and for helping us make PEAR better. see the release notes for 1.5.1 (there is a example of it in tests/simple.phpt) Thanks Alan
 [2004-01-22 17:37 UTC] fredrick dot leitz at sjrb dot ca
The fix only fixes the problem when the ini file reads: sequence_response = response_id:response_response_id_seq when the ini file is set to: sequence_response = response_response_id_seq the problem still exists.
 [2004-01-23 01:50 UTC] alan_k
The documentation always said that sequence_{table} = {column} so it never allowed you to set the sequence name before.. (although the code was a bit borked in that area..) now It's behavior should be consistant with what docs there are... .. - the long term hope is for the DB driver to use default nextvals / or to at least return them on tableinfo() I'm not sure there is much more to do here.. - but I'm open to ideas.