Changeset 7991
- Timestamp:
- 03/20/08 00:51:16 (7 months ago)
- Files:
-
- branches/dwhittle/1.1/lib/plugins/sfPropelPlugin/lib/vendor/propel-generator/classes/propel/engine/builder/om/php5/PHP5PeerBuilder.php (modified) (2 diffs)
- branches/dwhittle/1.1/lib/plugins/sfPropelPlugin/lib/vendor/propel-generator/classes/propel/engine/database/model/Table.php (modified) (5 diffs)
- branches/dwhittle/1.1/lib/plugins/sfPropelPlugin/lib/vendor/propel-generator/classes/propel/engine/database/reverse/mysql/MysqlSchemaParser.php (modified) (5 diffs)
- branches/dwhittle/1.1/lib/plugins/sfPropelPlugin/lib/vendor/propel-generator/projects/bookstore/build.properties (modified) (2 diffs)
- branches/dwhittle/1.1/lib/plugins/sfPropelPlugin/lib/vendor/propel-generator/projects/bookstore/schema.xml (modified) (1 diff)
- branches/dwhittle/1.1/lib/plugins/sfPropelPlugin/lib/vendor/propel-generator/resources/xsd/database.xsd (modified) (1 diff)
- branches/dwhittle/1.1/lib/plugins/sfPropelPlugin/lib/vendor/propel-generator/test/classes/propel/GeneratedObjectTest.php (modified) (2 diffs)
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 2 2 3 3 /* 4 * $Id: PHP5PeerBuilder.php 100 1 2008-03-16 20:43:29Z hans$4 * $Id: PHP5PeerBuilder.php 1009 2008-03-19 22:15:23Z soenke $ 5 5 * 6 6 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS … … 1061 1061 foreach ($table->getColumns() as $col) { 1062 1062 $cfc = $col->getPhpName(); 1063 if ($col->isPrimaryKey() && $col->isAutoIncrement() && $table->getIdMethod() != "none" ) {1063 if ($col->isPrimaryKey() && $col->isAutoIncrement() && $table->getIdMethod() != "none" && !$table->isAllowPkInsert()) { 1064 1064 $script .= " 1065 1065 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 2 2 3 3 /* 4 * $Id: Table.php 989 2008-03-11 14:29:30Z heltem$4 * $Id: Table.php 1009 2008-03-19 22:15:23Z soenke $ 5 5 * 6 6 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS … … 41 41 * @author Daniel Rall <dlr@collab.net> (Torque) 42 42 * @author Byron Foster <byron_foster@yahoo.com> (Torque) 43 * @version $Revision: 989 $43 * @version $Revision: 1009 $ 44 44 * @package propel.engine.database.model 45 45 */ … … 122 122 123 123 /** 124 * Wether an INSERT with set PK is allowed on tables with IDMethod::NATIVE 125 * 126 * @var boolean 127 */ 128 private $allowPkInsert; 129 130 /** 124 131 * Strategry to use for converting column name to phpName. 125 132 * … … 295 302 $this->phpName = $this->getAttribute("phpName"); 296 303 $this->idMethod = $this->getAttribute("idMethod", $this->getDatabase()->getDefaultIdMethod()); 304 $this->allowPkInsert = $this->booleanValue($this->getAttribute("allowPkInsert")); 297 305 298 306 // retrieves the method for converting from specified name to a PHP name. … … 820 828 821 829 /** 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 /** 822 842 * Set the method for generating pk's 823 843 */ branches/dwhittle/1.1/lib/plugins/sfPropelPlugin/lib/vendor/propel-generator/classes/propel/engine/database/reverse/mysql/MysqlSchemaParser.php
r7809 r7991 1 1 <?php 2 2 /* 3 * $Id: MysqlSchemaParser.php 989 2008-03-11 14:29:30Z heltem$3 * $Id: MysqlSchemaParser.php 1010 2008-03-19 23:08:08Z hans $ 4 4 * 5 5 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS … … 26 26 * 27 27 * @author Hans Lellelid <hans@xmpl.org> 28 * @version $Revision: 989$28 * @version $Revision: 1010 $ 29 29 * @package propel.engine.database.reverse.mysql 30 30 */ … … 199 199 200 200 // Get the information on all the foreign keys 201 $regEx = '/CONSTRAINT `([^`]+)` FOREIGN KEY \( `([^`]*)`\) REFERENCES `([^`]*)` \(`([^`]*)`\)(.*)/';201 $regEx = '/CONSTRAINT `([^`]+)` FOREIGN KEY \((.+)\) REFERENCES `([^`]*)` \((.+)\)(.*)/'; 202 202 if (preg_match_all($regEx,$row[1],$matches)) { 203 203 $tmpArray = array_keys($matches[0]); 204 204 foreach ($tmpArray as $curKey) { 205 205 $name = $matches[1][$curKey]; 206 $ lcol = $matches[2][$curKey];206 $rawlcol = $matches[2][$curKey]; 207 207 $ftbl = $matches[3][$curKey]; 208 $ fcol = $matches[4][$curKey];208 $rawfcol = $matches[4][$curKey]; 209 209 $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 211 221 //typical for mysql is RESTRICT 212 222 $fkactions = array( … … 225 235 } 226 236 } 227 237 238 $localColumns = array(); 239 $foreignColumns = array(); 240 228 241 $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 } 231 249 232 250 if (!isset($foreignKeys[$name])) { … … 238 256 $foreignKeys[$name] = $fk; 239 257 } 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 241 263 } 242 264 branches/dwhittle/1.1/lib/plugins/sfPropelPlugin/lib/vendor/propel-generator/projects/bookstore/build.properties
r7955 r7991 1 # $Id: build.properties 10 03 2008-03-18 13:55:51Z hans $1 # $Id: build.properties 1010 2008-03-19 23:08:08Z hans $ 2 2 # 3 3 # This is a project-specific build.properties file. The properties … … 14 14 propel.database = mysql 15 15 propel.database.url = mysql:dbname=test 16 propel.mysqlTableType = InnoDB 16 17 propel.disableIdentifierQuoting=true 17 18 branches/dwhittle/1.1/lib/plugins/sfPropelPlugin/lib/vendor/propel-generator/projects/bookstore/schema.xml
r7772 r7991 269 269 </table> 270 270 271 <table name="customer" >271 <table name="customer" allowPkInsert="true"> 272 272 <column name="id" type="INTEGER" primaryKey="true" 273 273 autoIncrement="true" /> branches/dwhittle/1.1/lib/plugins/sfPropelPlugin/lib/vendor/propel-generator/resources/xsd/database.xsd
r7042 r7991 352 352 <xs:attribute name="defaultMutatorVisibility" type="visibility" use="optional"/> 353 353 <xs:attribute name="idMethod" type="idmethod" use='optional'/> 354 <xs:attribute name="allowPkInsert" type="xs:boolean" default="false" use="optional"/> 354 355 <xs:attribute name="skipSql" type="xs:boolean" default="false"/> 355 356 <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 1 1 <?php 2 2 /* 3 * $Id: GeneratedObjectTest.php 989 2008-03-11 14:29:30Z heltem$3 * $Id: GeneratedObjectTest.php 1007 2008-03-19 22:01:26Z soenke $ 4 4 * 5 5 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS … … 954 954 // success ... 955 955 } 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 } 956 990 }