Req #4418 [NEW]: Clarification of DB::nextId & sequence reqs
| From: | apthorpe at cynistar dot net | Date: | Tue, 24 May 2005 14:35:17 +0000 |
| Subject: | Req #4418 [NEW]: Clarification of DB::nextId & sequence reqs | ||
| Groups: | php.pear.doc | ||
| Request: | Send a blank email to pear-doc+get-6081@lists.php.net to get a copy of this message | ||
From: apthorpe at cynistar dot net
Operating system: All
PHP version: 4.3.4
Package: Documentation
Bug Type: Feature/Change Request
Bug description: Clarification of DB::nextId & sequence reqs
Description:
------------
Based on the current documentation for PEAR DB, regarding sequences:
1. It's not clear that CREATE permission is needed to use
DB::nextId($seq_name, $onDemand) when $onDemand is set to TRUE (default.)
2. There are implied limitations on the contents of $seq_name. For
example, using $seq_name = 'staff.staff_id' with MySQL will cause the
sequence table name to be generated as 'staff.staff_id_seq' - the '.'
causes MySQL to interpret 'staff' as the database and 'staff_id_seq' as
the table name. In retrospect this is expected, but it's not obvious
unless you understand the implemenation of sequences in PEAR::DB. One of
three things should happen: 1) special characters in $seq_name should be
stripped or encoded, 2) an error should be thrown if $seq_name contains
special characters, or 3) the documentation should explicitly suggest safe
characters to use in $seq_name, or at least warn against using special
characters.
3. DB::nextId() on a existing table will not work if used on a table with
IDs that were assigned before nextId() was first used. One must manually
set the id column in the sequence table to MAX(id) before using nextId().
While it's doubtful that DB could be made psychic enough to do this
automatically, the documentation should warn against using nextId() on an
existing table without dumping/reinserting the data using nextId() or
adjusting the sequence id manually.
Thank you for taking the time to read this and for releasing and
maintaining PEAR::DB
--
Edit bug report at http://pear.php.net/bugs/bug.php?id=4418&edit=1
--