DataObject Postgres, native sequences

From: Date: Wed, 12 Jan 2005 22:15:09 +0000
Subject: DataObject Postgres, native sequences
Groups: php.pear.dev 
Request: Send a blank email to pear-dev+get-35475@lists.php.net to get a copy of this message
Below is a patch vs. DO (that works for me) to use the proper native sequences (those defined in the table definition) for SERIAL types in Postgresql. 1) This assumes that any key with a value 'N' is native and calls nextval for it's value. This follows Generator.php which assigns 'N' only to those types. (If people write their ini files by hand they should follow the standard!) 2) !!The big problem is this now starts using native sequences by default, so it breaks code that depends on sequences automagically created by DB!! I'd really like to see DO work this way, but wanted to first see what others thought. Where does this not work? How much old code will this break? matt RCS file: /repository/pear/DB_DataObject/DataObject.php,v retrieving revision 1.309 diff -r1.309 DataObject.php 990a991,1001
// by this point we know this is a nextval field in postgres $defs = $DB->tableInfo($this->__table);
      foreach($defs as $def){
          if ($def['name'] == $key) {
            $f = rawurldecode($def['flags']);
            if (preg_match("/nextval\((.*)\)/i", $f, $seqs)) {
              $seq = $seqs[1];
            }
            break;
          }
      }
1843c1854,1856
<	if (    in_array($dbtype , array( 'mysql', 'mssql')) &&
---
      // this can safely add postgres since we know from Generator that
      // $realkeys[$usekey] == N means its a 'nextval' field
      if (    in_array($dbtype , array( 'mysql', 'mssql', 'pgsql')) &&


« previous php.pear.dev (#35475) next »