Skip to content

Commit

Permalink
Automatic update
Browse files Browse the repository at this point in the history
  • Loading branch information
xosofox committed Jun 1, 2011
1 parent 9168545 commit 1f089d6
Show file tree
Hide file tree
Showing 9 changed files with 59 additions and 44 deletions.
4 changes: 3 additions & 1 deletion generator/lib/builder/om/OMBuilder.php
Original file line number Diff line number Diff line change
Expand Up @@ -505,7 +505,9 @@ public function applyBehaviorModifierBase($hookName, $modifier, &$script, $tab =
$modifier->$hookName($script, $this);
} else {
// regular hook: the behavior returns a string to append to the script string
$script .= "\n" . $tab . '// ' . $behavior->getName() . " behavior\n";
$script .= "
" . $tab . '// ' . $behavior->getName() . " behavior
";
$script .= preg_replace('/^/m', $tab, $modifier->$hookName($this));
}
}
Expand Down
2 changes: 1 addition & 1 deletion generator/lib/builder/om/PHP5ObjectBuilder.php
Original file line number Diff line number Diff line change
Expand Up @@ -1690,7 +1690,7 @@ protected function addBooleanMutator(&$script, Column $col)
$script .= "
if (\$v !== null) {
if (is_string(\$v)) {
\$v = in_array(strtolower(\$v), array('false', 'off', '-', 'no', 'n', '0')) ? false : true;
\$v = in_array(strtolower(\$v), array('false', 'off', '-', 'no', 'n', '0', '')) ? false : true;
} else {
\$v = (boolean) \$v;
}
Expand Down
12 changes: 8 additions & 4 deletions generator/lib/builder/om/PHP5PeerBuilder.php
Original file line number Diff line number Diff line change
Expand Up @@ -2077,22 +2077,26 @@ public function addCriteriaJoin($fk, $table, $joinTable, $joinedTablePeerBuilder
// simple foreign key
$lftCol = $lftCols[0];
$script .= sprintf("
\$criteria->addJoin(%s, %s, \$join_behavior);\n",
\$criteria->addJoin(%s, %s, \$join_behavior);
",
$this->getColumnConstant($table->getColumn($lftCol) ),
$joinedTablePeerBuilder->getColumnConstant($joinTable->getColumn( $lfMap[$lftCol] ) ));
}
else
{
// composite foreign key
$script .= "
\$criteria->addMultipleJoin(array(\n";
\$criteria->addMultipleJoin(array(
";
foreach ($lftCols as $columnName ) {
$script .= sprintf(" array(%s, %s),\n",
$script .= sprintf(" array(%s, %s),
",
$this->getColumnConstant($table->getColumn($columnName) ),
$joinedTablePeerBuilder->getColumnConstant($joinTable->getColumn( $lfMap[$columnName] ) )
);
}
$script .= " ), \$join_behavior);\n";
$script .= " ), \$join_behavior);
";
}
return $script;
}
Expand Down
2 changes: 1 addition & 1 deletion generator/lib/builder/om/QueryBuilder.php
Original file line number Diff line number Diff line change
Expand Up @@ -741,7 +741,7 @@ public function filterBy$colPhpName(\$$variableName = null, \$comparison = null)
} elseif ($col->isBooleanType()) {
$script .= "
if (is_string(\$$variableName)) {
\$$colName = in_array(strtolower(\$$variableName), array('false', 'off', '-', 'no', 'n', '0')) ? false : true;
\$$colName = in_array(strtolower(\$$variableName), array('false', 'off', '-', 'no', 'n', '0', '')) ? false : true;
}";
}
$script .= "
Expand Down
17 changes: 10 additions & 7 deletions generator/lib/platform/DefaultPlatform.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
* Default implementation for the Platform interface.
*
* @author Martin Poeschl <mpoeschl@marmot.at> (Torque)
* @version $Revision: 2281 $
* @version $Revision: 2311 $
* @package propel.generator.platform
*/
class DefaultPlatform implements PropelPlatformInterface
Expand Down Expand Up @@ -627,22 +627,25 @@ public function getCommentBlockDDL($comment)
public function getModifyDatabaseDDL(PropelDatabaseDiff $databaseDiff)
{
$ret = $this->getBeginDDL();

foreach ($databaseDiff->getRemovedTables() as $table) {
$ret .= $this->getDropTableDDL($table);
}

foreach ($databaseDiff->getRenamedTables() as $fromTableName => $toTableName) {
$ret .= $this->getRenameTableDDL($fromTableName, $toTableName);
}


foreach ($databaseDiff->getAddedTables() as $table) {
$ret .= $this->getAddTableDDL($table);
$ret .= $this->getAddIndicesDDL($table);
}

foreach ($databaseDiff->getModifiedTables() as $tableDiff) {
$ret .= $this->getModifyTableDDL($tableDiff);
}

foreach ($databaseDiff->getAddedTables() as $table) {
$ret .= $this->getAddTableDDL($table);
$ret .= $this->getAddIndicesDDL($table);
$ret .= $this->getAddForeignKeysDDL($table);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ public function providerForSetter()
array('N', false),
array('+', true),
array('-', false),
array('', false),
);
}

Expand Down
5 changes: 5 additions & 0 deletions test/testsuite/generator/builder/om/QueryBuilderTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -507,6 +507,11 @@ public function testFilterByBoolean()
$q = ReviewQuery::create()->filterByRecommended('0');
$q1 = ReviewQuery::create()->add(ReviewPeer::RECOMMENDED, false, Criteria::EQUAL);
$this->assertEquals($q1, $q, 'filterByBooleanColumn() translates to a = false when passed a false string');

$q = ReviewQuery::create()->filterByRecommended('');
$q1 = ReviewQuery::create()->add(ReviewPeer::RECOMMENDED, false, Criteria::EQUAL);
$this->assertEquals($q1, $q, 'filterByBooleanColumn() translates to a = false when passed an empty string');

}

public function testFilterByFk()
Expand Down
48 changes: 24 additions & 24 deletions test/testsuite/generator/platform/OraclePlatformMigrationTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -44,18 +44,6 @@ public function testGetModifyDatabaseDDL($databaseDiff)
ALTER TABLE foo3 RENAME TO foo4;
ALTER TABLE foo2 RENAME COLUMN bar TO bar1;
ALTER TABLE foo2 MODIFY
(
baz NVARCHAR2(12)
);
ALTER TABLE foo2 ADD
(
baz3 NVARCHAR2(2000)
);
CREATE TABLE foo5
(
id NUMBER NOT NULL,
Expand All @@ -67,6 +55,18 @@ public function testGetModifyDatabaseDDL($databaseDiff)
CREATE SEQUENCE foo5_SEQ
INCREMENT BY 1 START WITH 1 NOMAXVALUE NOCYCLE NOCACHE ORDER;
ALTER TABLE foo2 RENAME COLUMN bar TO bar1;
ALTER TABLE foo2 MODIFY
(
baz NVARCHAR2(12)
);
ALTER TABLE foo2 ADD
(
baz3 NVARCHAR2(2000)
);
";
$this->assertEquals($expected, $this->getPlatform()->getModifyDatabaseDDL($databaseDiff));
}
Expand Down Expand Up @@ -393,18 +393,6 @@ public function testGetModifyDatabaseWithBlockStorageDDL()
ALTER TABLE foo3 RENAME TO foo4;
ALTER TABLE foo2 RENAME COLUMN bar TO bar1;
ALTER TABLE foo2 MODIFY
(
baz NVARCHAR2(12)
);
ALTER TABLE foo2 ADD
(
baz3 CLOB
);
CREATE TABLE foo5
(
id NUMBER NOT NULL,
Expand Down Expand Up @@ -446,6 +434,18 @@ public function testGetModifyDatabaseWithBlockStorageDDL()
PCTINCREASE 0
)
TABLESPACE L_128K;
ALTER TABLE foo2 RENAME COLUMN bar TO bar1;
ALTER TABLE foo2 MODIFY
(
baz NVARCHAR2(12)
);
ALTER TABLE foo2 ADD
(
baz3 CLOB
);
";
$this->assertEquals($expected, $this->getPlatform()->getModifyDatabaseDDL($databaseDiff));
}
Expand Down
12 changes: 6 additions & 6 deletions test/testsuite/generator/platform/PgsqlPlatformMigrationTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -40,12 +40,6 @@ public function testGetModifyDatabaseDDL($databaseDiff)
ALTER TABLE "foo3" RENAME TO "foo4";
ALTER TABLE "foo2" RENAME COLUMN "bar" TO "bar1";
ALTER TABLE "foo2" ALTER COLUMN "baz" DROP NOT NULL;
ALTER TABLE "foo2" ADD "baz3" TEXT;
CREATE TABLE "foo5"
(
"id" serial NOT NULL,
Expand All @@ -54,6 +48,12 @@ public function testGetModifyDatabaseDDL($databaseDiff)
PRIMARY KEY ("id")
);
ALTER TABLE "foo2" RENAME COLUMN "bar" TO "bar1";
ALTER TABLE "foo2" ALTER COLUMN "baz" DROP NOT NULL;
ALTER TABLE "foo2" ADD "baz3" TEXT;
END;
$this->assertEquals($expected, $this->getPlatform()->getModifyDatabaseDDL($databaseDiff));
}
Expand Down

0 comments on commit 1f089d6

Please sign in to comment.