Ticket #870: generator-15b1-patch.diff
| File generator-15b1-patch.diff, 5.5 KB (added by lvanderree, 6 months ago) |
|---|
-
lib/builder/om/PHP5TableMapBuilder.php
268 268 $columnMapping .= ')'; 269 269 $onDelete = $fkey->hasOnDelete() ? "'" . $fkey->getOnDelete() . "'" : 'null'; 270 270 $onUpdate = $fkey->hasOnUpdate() ? "'" . $fkey->getOnUpdate() . "'" : 'null'; 271 $preferedJoinType = $fkey->hasPreferedJoinType() ? "'" . $fkey->getPreferedJoinType() . "'" : 'null'; 271 272 $script .= " 272 \$this->addRelation('" . $this->getFKPhpNameAffix($fkey) . "', '" . $fkey->getForeignTable()->getPhpName() . "', RelationMap::MANY_TO_ONE, $columnMapping, $onDelete, $onUpdate );";273 \$this->addRelation('" . $this->getFKPhpNameAffix($fkey) . "', '" . $fkey->getForeignTable()->getPhpName() . "', RelationMap::MANY_TO_ONE, $columnMapping, $onDelete, $onUpdate, $preferedJoinType);"; 273 274 } 274 275 foreach ($this->getTable()->getReferrers() as $fkey) 275 276 { … … 281 282 $columnMapping .= ')'; 282 283 $onDelete = $fkey->hasOnDelete() ? "'" . $fkey->getOnDelete() . "'" : 'null'; 283 284 $onUpdate = $fkey->hasOnUpdate() ? "'" . $fkey->getOnUpdate() . "'" : 'null'; 285 $preferedJoinType = $fkey->hasPreferedJoinType() ? "'" . $fkey->getPreferedJoinType() . "'" : 'null'; 284 286 $script .= " 285 \$this->addRelation('" . $this->getRefFKPhpNameAffix($fkey) . "', '" . $fkey->getTable()->getPhpName() . "', RelationMap::ONE_TO_" . ($fkey->isLocalPrimaryKey() ? "ONE" : "MANY") .", $columnMapping, $onDelete, $onUpdate );";287 \$this->addRelation('" . $this->getRefFKPhpNameAffix($fkey) . "', '" . $fkey->getTable()->getPhpName() . "', RelationMap::ONE_TO_" . ($fkey->isLocalPrimaryKey() ? "ONE" : "MANY") .", $columnMapping, $onDelete, $onUpdate, $preferedJoinType);"; 286 288 } 287 289 foreach ($this->getTable()->getCrossFks() as $fkList) 288 290 { 289 291 list($refFK, $crossFK) = $fkList; 290 292 $onDelete = $fkey->hasOnDelete() ? "'" . $fkey->getOnDelete() . "'" : 'null'; 291 293 $onUpdate = $fkey->hasOnUpdate() ? "'" . $fkey->getOnUpdate() . "'" : 'null'; 294 $preferedJoinType = $fkey->hasPreferedJoinType() ? "'" . $fkey->getPreferedJoinType() . "'" : 'null'; 292 295 $script .= " 293 \$this->addRelation('" . $this->getFKPhpNameAffix($crossFK) . "', '" . $crossFK->getForeignTable()->getPhpName() . "', RelationMap::MANY_TO_MANY, array(), $onDelete, $onUpdate );";296 \$this->addRelation('" . $this->getFKPhpNameAffix($crossFK) . "', '" . $crossFK->getForeignTable()->getPhpName() . "', RelationMap::MANY_TO_MANY, array(), $onDelete, $onUpdate, $preferedJoinType);"; 294 297 } 295 298 $script .= " 296 299 } // buildRelations() -
lib/model/ForeignKey.php
39 39 protected $refPhpName; 40 40 protected $onUpdate; 41 41 protected $onDelete; 42 protected $preferedJoinType; 42 43 protected $parentTable; 43 44 protected $localColumns = array(); 44 45 protected $foreignColumns = array(); … … 50 51 const RESTRICT = "RESTRICT"; 51 52 const SETDEFAULT = "SET DEFAULT"; 52 53 const SETNULL = "SET NULL"; 54 const INNERJOIN = "INNER JOIN"; 53 55 54 56 /** 55 57 * Constructs a new ForeignKey object. … … 73 75 $this->refPhpName = $this->getAttribute("refPhpName"); 74 76 $this->onUpdate = $this->normalizeFKey($this->getAttribute("onUpdate")); 75 77 $this->onDelete = $this->normalizeFKey($this->getAttribute("onDelete")); 78 $this->preferedJoinType = $this->getAttribute("preferedJoinType"); 76 79 } 77 80 78 81 /** … … 98 101 return ($this->onUpdate !== self::NONE); 99 102 } 100 103 104 /** 105 * returns whether or not the preferedJoinType attribute is set 106 */ 107 public function hasPreferedJoinType() 108 { 109 return ($this->preferedJoinType !== self::NONE); 110 } 111 101 112 /** 102 113 * returns whether or not the onDelete attribute is set 103 114 */ … … 114 125 { 115 126 return $this->onUpdate; 116 127 } 128 129 /** 130 * returns the preferedJoinType attribute 131 * @return string 132 */ 133 public function getPreferedJoinType() 134 { 135 return $this->preferedJoinType ? $this->preferedJoinType : self::INNERJOIN; 136 } 117 137 118 138 /** 119 139 * Returns the onDelete attribute … … 139 159 { 140 160 $this->onUpdate = $this->normalizeFKey($value); 141 161 } 142 162 163 /** 164 * sets the preferedJoinType attribute 165 */ 166 public function setPreferedJoinType($value) 167 { 168 $this->preferedJoinType = $value; 169 } 170 143 171 /** 144 172 * Returns the name attribute. 145 173 */ … … 456 484 $fkNode->setAttribute('onUpdate', $this->getOnUpdate()); 457 485 } 458 486 487 if ($this->getPreferedJoinType()) { 488 $fkNode->setAttribute('preferedJoinType', $this->getPreferedJoinType()); 489 } 490 459 491 for ($i=0, $size=count($this->localColumns); $i < $size; $i++) { 460 492 $refNode = $fkNode->appendChild($doc->createElement('reference')); 461 493 $refNode->setAttribute('local', $this->localColumns[$i]); -
resources/xsd/database.xsd
335 335 <xs:attribute name="name" type="foreign_name" use="optional"/> 336 336 <xs:attribute name="phpName" type="php_name" use="optional"/> 337 337 <xs:attribute name="refPhpName" type="php_name" use="optional"/> 338 <xs:attribute name="preferedJoinType" type="xs:string" use="optional"/> 338 339 <xs:attribute name="onDelete" type="delete" default="none"/> 339 340 <xs:attribute name="onUpdate" type="update" default="none"/> 340 341 </xs:complexType>