Development

Changeset 7991

You must first sign up to be able to contribute.

Changeset 7991

Show
Ignore:
Timestamp:
03/20/08 00:51:16 (7 months ago)
Author:
dwhittle
Message:

dwhittle: merged propel bug fixes to branch

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • branches/dwhittle/1.1/lib/plugins/sfPropelPlugin/lib/vendor/propel-generator/classes/propel/engine/builder/om/php5/PHP5PeerBuilder.php

    r7955 r7991  
    22 
    33/* 
    4  *  $Id: PHP5PeerBuilder.php 1001 2008-03-16 20:43:29Z hans
     4 *  $Id: PHP5PeerBuilder.php 1009 2008-03-19 22:15:23Z soenke
    55 * 
    66 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 
     
    10611061    foreach ($table->getColumns() as $col) { 
    10621062      $cfc = $col->getPhpName(); 
    1063       if ($col->isPrimaryKey() && $col->isAutoIncrement() && $table->getIdMethod() != "none") { 
     1063      if ($col->isPrimaryKey() && $col->isAutoIncrement() && $table->getIdMethod() != "none" && !$table->isAllowPkInsert()) { 
    10641064        $script .= " 
    10651065    if (\$criteria->containsKey(".$this->getColumnConstant($col).")) { 
  • branches/dwhittle/1.1/lib/plugins/sfPropelPlugin/lib/vendor/propel-generator/classes/propel/engine/database/model/Table.php

    r7809 r7991  
    22 
    33/* 
    4  *  $Id: Table.php 989 2008-03-11 14:29:30Z heltem
     4 *  $Id: Table.php 1009 2008-03-19 22:15:23Z soenke
    55 * 
    66 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 
     
    4141 * @author     Daniel Rall <dlr@collab.net> (Torque) 
    4242 * @author     Byron Foster <byron_foster@yahoo.com> (Torque) 
    43  * @version    $Revision: 989 $ 
     43 * @version    $Revision: 1009 $ 
    4444 * @package    propel.engine.database.model 
    4545 */ 
     
    122122 
    123123  /** 
     124   * Wether an INSERT with set PK is allowed on tables with IDMethod::NATIVE 
     125   * 
     126   * @var        boolean 
     127   */ 
     128  private $allowPkInsert; 
     129 
     130  /** 
    124131   * Strategry to use for converting column name to phpName. 
    125132   * 
     
    295302    $this->phpName = $this->getAttribute("phpName"); 
    296303    $this->idMethod = $this->getAttribute("idMethod", $this->getDatabase()->getDefaultIdMethod()); 
     304    $this->allowPkInsert = $this->booleanValue($this->getAttribute("allowPkInsert")); 
    297305 
    298306    // retrieves the method for converting from specified name to a PHP name. 
     
    820828 
    821829  /** 
     830   * Whether we allow to insert primary keys on tables with 
     831   * idMethod=native 
     832   * 
     833   * @return     boolean 
     834   */ 
     835  public function isAllowPkInsert() 
     836  { 
     837    return $this->allowPkInsert; 
     838  } 
     839 
     840 
     841  /** 
    822842   * Set the method for generating pk's 
    823843   */ 
  • branches/dwhittle/1.1/lib/plugins/sfPropelPlugin/lib/vendor/propel-generator/classes/propel/engine/database/reverse/mysql/MysqlSchemaParser.php

    r7809 r7991  
    11<?php 
    22/* 
    3  *  $Id: MysqlSchemaParser.php 989 2008-03-11 14:29:30Z heltem
     3 *  $Id: MysqlSchemaParser.php 1010 2008-03-19 23:08:08Z hans
    44 * 
    55 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 
     
    2626 * 
    2727 * @author     Hans Lellelid <hans@xmpl.org> 
    28  * @version    $Revision: 989
     28 * @version    $Revision: 1010
    2929 * @package    propel.engine.database.reverse.mysql 
    3030 */ 
     
    199199 
    200200    // Get the information on all the foreign keys 
    201     $regEx = '/CONSTRAINT `([^`]+)` FOREIGN KEY \(`([^`]*)`\) REFERENCES `([^`]*)` \(`([^`]*)`\)(.*)/'; 
     201    $regEx = '/CONSTRAINT `([^`]+)` FOREIGN KEY \((.+)\) REFERENCES `([^`]*)` \((.+)\)(.*)/'; 
    202202    if (preg_match_all($regEx,$row[1],$matches)) { 
    203203      $tmpArray = array_keys($matches[0]); 
    204204      foreach ($tmpArray as $curKey) { 
    205205        $name = $matches[1][$curKey]; 
    206         $lcol = $matches[2][$curKey]; 
     206        $rawlcol = $matches[2][$curKey]; 
    207207        $ftbl = $matches[3][$curKey]; 
    208         $fcol = $matches[4][$curKey]; 
     208        $rawfcol = $matches[4][$curKey]; 
    209209        $fkey = $matches[5][$curKey]; 
    210  
     210         
     211        $lcols = array(); 
     212        foreach(preg_split('/`, `/', $rawlcol) as $piece) { 
     213          $lcols[] = trim($piece, '` '); 
     214        } 
     215         
     216        $fcols = array(); 
     217        foreach(preg_split('/`, `/', $rawfcol) as $piece) { 
     218          $fcols[] = trim($piece, '` '); 
     219        } 
     220         
    211221        //typical for mysql is RESTRICT 
    212222        $fkactions = array( 
     
    225235          } 
    226236        } 
    227  
     237         
     238        $localColumns = array(); 
     239        $foreignColumns = array(); 
     240         
    228241        $foreignTable = $database->getTable($ftbl); 
    229         $foreignColumn = $foreignTable->getColumn($fcol); 
    230         $localColumn   = $table->getColumn($lcol); 
     242         
     243        foreach($fcols as $fcol) { 
     244          $foreignColumns[] = $foreignTable->getColumn($fcol); 
     245        } 
     246        foreach($lcols as $lcol) { 
     247          $localColumns[] = $table->getColumn($lcol); 
     248        } 
    231249 
    232250        if (!isset($foreignKeys[$name])) { 
     
    238256          $foreignKeys[$name] = $fk; 
    239257        } 
    240         $foreignKeys[$name]->addReference($localColumn, $foreignColumn); 
     258         
     259        for($i=0; $i < count($localColumns); $i++) { 
     260          $foreignKeys[$name]->addReference($localColumns[$i], $foreignColumns[$i]); 
     261        } 
     262         
    241263      } 
    242264 
  • branches/dwhittle/1.1/lib/plugins/sfPropelPlugin/lib/vendor/propel-generator/projects/bookstore/build.properties

    r7955 r7991  
    1 # $Id: build.properties 1003 2008-03-18 13:55:51Z hans $ 
     1# $Id: build.properties 1010 2008-03-19 23:08:08Z hans $ 
    22#  
    33# This is a project-specific build.properties file.  The properties 
     
    1414propel.database = mysql  
    1515propel.database.url = mysql:dbname=test 
     16propel.mysqlTableType = InnoDB 
    1617propel.disableIdentifierQuoting=true 
    1718 
  • branches/dwhittle/1.1/lib/plugins/sfPropelPlugin/lib/vendor/propel-generator/projects/bookstore/schema.xml

    r7772 r7991  
    269269  </table> 
    270270 
    271   <table name="customer"
     271  <table name="customer" allowPkInsert="true"
    272272    <column name="id" type="INTEGER" primaryKey="true" 
    273273      autoIncrement="true" /> 
  • branches/dwhittle/1.1/lib/plugins/sfPropelPlugin/lib/vendor/propel-generator/resources/xsd/database.xsd

    r7042 r7991  
    352352    <xs:attribute name="defaultMutatorVisibility" type="visibility" use="optional"/> 
    353353    <xs:attribute name="idMethod" type="idmethod" use='optional'/> 
     354    <xs:attribute name="allowPkInsert" type="xs:boolean" default="false" use="optional"/> 
    354355    <xs:attribute name="skipSql" type="xs:boolean" default="false"/> 
    355356    <xs:attribute name="readOnly" type="xs:boolean" default="false"/> 
  • branches/dwhittle/1.1/lib/plugins/sfPropelPlugin/lib/vendor/propel-generator/test/classes/propel/GeneratedObjectTest.php

    r7809 r7991  
    11<?php 
    22/* 
    3  *  $Id: GeneratedObjectTest.php 989 2008-03-11 14:29:30Z heltem
     3 *  $Id: GeneratedObjectTest.php 1007 2008-03-19 22:01:26Z soenke
    44 * 
    55 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 
     
    954954    // success ... 
    955955  } 
     956   
     957  /** 
     958   * Checks wether we are allowed to specify the primary key on a  
     959   * table with allowPkInsert=true set 
     960         * 
     961   * saves the object, gets it from data-source again and then compares 
     962   * them for equality (thus the instance pool is also checked)  
     963   */ 
     964  public function testAllowPkInsertOnIdMethodNativeTable() 
     965  { 
     966    $cu = new Customer; 
     967    $cu->setPrimaryKey(100000); 
     968     
     969    $cu->save(); 
     970     
     971    $cu2 = CustomerPeer::retrieveByPk(100000); 
     972         
     973    $this->assertSame($cu, $cu2); 
     974  } 
     975   
     976  /** 
     977   * test the forbiddenness of setting the PK with idMethod=native 
     978   */ 
     979  public function testDontAllowPkInsertOnIdMethodNativeTable() 
     980  { 
     981    $b = new Book; 
     982    $b->setPrimaryKey(1000); 
     983    try { 
     984      $b->save(); 
     985      $this->fail("Propel must throw an exception if a PK was set by the user and the table has idMethod=native"); 
     986    } catch (PropelException $e) { 
     987      // [SR] as of XXX this throws an exception so everything is fine 
     988    } 
     989  } 
    956990}