[development] Why does the 'name' key in {sequences} have the table prefix prepended?

Rob Thorne rob at torenware.com
Thu Feb 2 19:25:57 UTC 2006


The CivicSpace folks are fixing a minor issue with their installer.  
Part of the problem is a quirk in the way that Drupal's database-neutral 
code handles sequence numbers.

For the node table, for example,  node_save calls the following code:

    $node->nid = db_next_id
    <http://drupaldocs.org/api/4.6/function/db_next_id>('{node}_nid'); 

So if you have a table prefix of "myprefix_",  the actual key in the 
{sequence} table (where db_next_id() is saving away the last value of 
the sequence number is going to "myprefix_node_nid", rather than "node_nid".

Why is this?  This is one of the few places I know of that the table 
prefix gets pushed into the database.  Having had to change the table 
prefix for a client before, I've been bitten by this a couple of times 
myself.

Is there any reason why we could *not* do this?

Rob Thorne
Torenware Networks


More information about the development mailing list