Skip to content
Browse files

Move constants to generated table maps

  • Loading branch information...
1 parent 27902cc commit db44afda2ab2333c025daa709a1d179624cabb1a @willdurand willdurand committed Jul 31, 2012
Showing with 425 additions and 364 deletions.
  1. +1 −1 src/Propel/Generator/Behavior/Archivable/ArchivableBehaviorQueryBuilderModifier.php
  2. +1 −1 src/Propel/Generator/Behavior/Archivable/templates/queryArchive.php
  3. +8 −0 src/Propel/Generator/Builder/Om/AbstractOMBuilder.php
  4. +13 −6 src/Propel/Generator/Builder/Om/ObjectBuilder.php
  5. +60 −91 src/Propel/Generator/Builder/Om/PeerBuilder.php
  6. +2 −1 src/Propel/Generator/Builder/Om/QueryBuilder.php
  7. +17 −9 src/Propel/Generator/Builder/Om/TableMapBuilder.php
  8. +44 −0 src/Propel/Generator/Builder/Om/templates/tableMapConstants.php
  9. +10 −6 src/Propel/Runtime/ActiveQuery/ModelCriteria.php
  10. +12 −1 src/Propel/Runtime/Collection/Collection.php
  11. +2 −1 tests/Propel/Tests/Generator/Behavior/AggregateColumn/AggregateColumnBehaviorWithSchemaTest.php
  12. +0 −1 tests/Propel/Tests/Generator/Behavior/ConcreteInheritance/ConcreteInheritanceBehaviorTest.php
  13. +0 −2 tests/Propel/Tests/Generator/Behavior/I18n/I18nBehaviorObjectBuilderModifierTest.php
  14. +1 −1 tests/Propel/Tests/Generator/Builder/NamespaceTest.php
  15. +3 −3 tests/Propel/Tests/Generator/Builder/Om/GeneratedObjectLazyLoadTest.php
  16. +3 −2 tests/Propel/Tests/Generator/Builder/Om/GeneratedObjectRelTest.php
  17. +12 −9 tests/Propel/Tests/Generator/Builder/Om/GeneratedObjectTest.php
  18. +8 −6 tests/Propel/Tests/Generator/Builder/Om/GeneratedPeerDoDeleteTest.php
  19. +6 −3 tests/Propel/Tests/Generator/Builder/Om/GeneratedPeerDoSelectTest.php
  20. +1 −1 tests/Propel/Tests/Generator/Builder/Om/GeneratedPeerLazyLoadTest.php
  21. +6 −4 tests/Propel/Tests/Generator/Builder/Om/QueryBuilderTest.php
  22. +3 −5 tests/Propel/Tests/Generator/Builder/Om/TableMapBuilderTest.php
  23. +4 −3 tests/Propel/Tests/Helpers/Bookstore/BookstoreDataPopulator.php
  24. +2 −3 tests/Propel/Tests/Helpers/Bookstore/BookstoreTestBase.php
  25. +11 −10 tests/Propel/Tests/Runtime/ActiveQuery/CriteriaMergeTest.php
  26. +36 −35 tests/Propel/Tests/Runtime/ActiveQuery/ModelCriteriaTest.php
  27. +9 −9 tests/Propel/Tests/Runtime/Adapter/DBAdapterTest.php
  28. +2 −2 tests/Propel/Tests/Runtime/Collection/CollectionTest.php
  29. +11 −10 tests/Propel/Tests/Runtime/Collection/ObjectCollectionWithFixturesTest.php
  30. +16 −15 tests/Propel/Tests/Runtime/Connection/PropelPDOTest.php
  31. +8 −10 tests/Propel/Tests/Runtime/Formatter/ArrayFormatterTest.php
  32. +10 −9 tests/Propel/Tests/Runtime/Formatter/ArrayFormatterWithTest.php
  33. +2 −2 tests/Propel/Tests/Runtime/Formatter/ObjectFormatterInheritanceTest.php
  34. +8 −8 tests/Propel/Tests/Runtime/Formatter/ObjectFormatterTest.php
  35. +17 −15 tests/Propel/Tests/Runtime/Formatter/ObjectFormatterWithTest.php
  36. +11 −12 tests/Propel/Tests/Runtime/Formatter/OnDemandFormatterTest.php
  37. +9 −9 tests/Propel/Tests/Runtime/Formatter/OnDemandFormatterWithTest.php
  38. +8 −9 tests/Propel/Tests/Runtime/Formatter/SimpleArrayFormatterTest.php
  39. +8 −9 tests/Propel/Tests/Runtime/Formatter/StatementFormatterTest.php
  40. +10 −10 tests/Propel/Tests/Runtime/Util/BasePeerExceptionsTest.php
  41. +30 −30 tests/Propel/Tests/Runtime/Util/BasePeerTest.php
View
2 src/Propel/Generator/Behavior/Archivable/ArchivableBehaviorQueryBuilderModifier.php
@@ -98,7 +98,7 @@ protected function addArchive($builder)
{
return $this->behavior->renderTemplate('queryArchive', array(
'archiveTablePhpName' => $this->behavior->getArchiveTablePhpName($builder),
- 'modelPeerName' => $builder->getPeerClassName(),
+ 'modelTableMap' => $builder->getTableMapClass(),
));
}
View
2 src/Propel/Generator/Behavior/Archivable/templates/queryArchive.php
@@ -23,7 +23,7 @@ public function archive($con = null, $useLittleMemory = true)
$criteria->setFormatter(ModelCriteria::FORMAT_ON_DEMAND);
}
if ($con === null) {
- $con = Propel::getServiceContainer()->getWriteConnection(<?php echo $modelPeerName ?>::DATABASE_NAME);
+ $con = Propel::getServiceContainer()->getWriteConnection(<?php echo $modelTableMap ?>::DATABASE_NAME);
}
$con->beginTransaction();
try {
View
8 src/Propel/Generator/Builder/Om/AbstractOMBuilder.php
@@ -782,6 +782,14 @@ public function renderTemplate($filename, $vars = array(), $templateDir = '/temp
}
/**
+ * @return string
+ */
+ public function getTableMapClass()
+ {
+ return $this->getStubObjectBuilder()->getUnqualifiedClassName() . 'TableMap';
+ }
+
+ /**
* Most of the code comes from the PHP-CS-Fixer project
*/
private function clean($content)
View
19 src/Propel/Generator/Builder/Om/ObjectBuilder.php
@@ -258,6 +258,8 @@ protected function addClassBody(&$script)
$this->declareClassFromBuilder($this->getStubObjectBuilder());
$this->declareClassFromBuilder($this->getStubPeerBuilder());
$this->declareClassFromBuilder($this->getStubQueryBuilder());
+ $this->declareClassFromBuilder($this->getTableMapBuilder());
+
$this->declareClasses(
'\Exception',
'\PDO',
@@ -380,6 +382,11 @@ protected function addConstants(&$script)
* Peer class name
*/
const PEER = '" . addslashes($this->getStubPeerBuilder()->getFullyQualifiedClassName()) . "';
+
+ /**
+ * TableMap class name
+ */
+ const TABLE_MAP = '" . addslashes($this->getTableMapBuilder()->getFullyQualifiedClassName()) . "';
";
}
@@ -2062,7 +2069,7 @@ protected function addHydrateBody(&$script)
\$this->ensureConsistency();
}
- return \$startcol + $n; // $n = ".$this->getPeerClassName()."::NUM_HYDRATE_COLUMNS.
+ return \$startcol + $n; // $n = ".$this->getTableMapClass()."::NUM_HYDRATE_COLUMNS.
} catch (Exception \$e) {
throw new PropelException(\"Error populating ".$this->getStubObjectBuilder()->getClassName()." object\", 0, \$e);
@@ -2131,7 +2138,7 @@ public function buildPkeyCriteria()
protected function addBuildPkeyCriteriaBody(&$script)
{
$script .= "
- \$criteria = new Criteria(".$this->getPeerClassName()."::DATABASE_NAME);";
+ \$criteria = new Criteria(".$this->getTableMapClass()."::DATABASE_NAME);";
foreach ($this->getTable()->getPrimaryKey() as $col) {
$clo = strtolower($col->getName());
$script .= "
@@ -2200,7 +2207,7 @@ public function buildCriteria()
protected function addBuildCriteriaBody(&$script)
{
$script .= "
- \$criteria = new Criteria(".$this->getPeerClassName()."::DATABASE_NAME);
+ \$criteria = new Criteria(".$this->getTableMapClass()."::DATABASE_NAME);
";
foreach ($this->getTable()->getColumns() as $col) {
$clo = strtolower($col->getName());
@@ -2621,7 +2628,7 @@ protected function addDeleteBody(&$script)
}
if (\$con === null) {
- \$con = Propel::getServiceContainer()->getWriteConnection(".$this->getPeerClassName()."::DATABASE_NAME);
+ \$con = Propel::getServiceContainer()->getWriteConnection(".$this->getTableMapClass()."::DATABASE_NAME);
}
\$con->beginTransaction();
@@ -2705,7 +2712,7 @@ public function reload(\$deep = false, ConnectionInterface \$con = null)
}
if (\$con === null) {
- \$con = Propel::getServiceContainer()->getReadConnection(".$this->getPeerClassName()."::DATABASE_NAME);
+ \$con = Propel::getServiceContainer()->getReadConnection(".$this->getTableMapClass()."::DATABASE_NAME);
}
// We don't need to alter the object instance pool; we're just modifying this instance
@@ -4667,7 +4674,7 @@ protected function addSaveBody(&$script)
}
if (\$con === null) {
- \$con = Propel::getServiceContainer()->getWriteConnection(".$this->getPeerClassName()."::DATABASE_NAME);
+ \$con = Propel::getServiceContainer()->getWriteConnection(".$this->getTableMapClass()."::DATABASE_NAME);
}
\$con->beginTransaction();
View
151 src/Propel/Generator/Builder/Om/PeerBuilder.php
@@ -185,14 +185,6 @@ protected function addStaticTableMapRegistration(&$script)
/**
* @return string
*/
- public function getTableMapClass()
- {
- return $this->getStubObjectBuilder()->getUnqualifiedClassName() . 'TableMap';
- }
-
- /**
- * @return string
- */
public function getTablePhpName()
{
return ($this->getTable()->isAbstract() ? '' : $this->getClassNameFromBuilder($this->getStubObjectBuilder()));
@@ -205,34 +197,6 @@ public function getTablePhpName()
*/
protected function addConstantsAndAttributes(&$script)
{
- $dbName = $this->getDatabase()->getName();
- $tableName = $this->getTable()->getName();
- $tablePhpName = $this->getTable()->isAbstract() ? '' : addslashes($this->getStubObjectBuilder()->getFullyQualifiedClassName());
- $script .= "
- /** the default database name for this class */
- const DATABASE_NAME = '$dbName';
-
- /** the table name for this class */
- const TABLE_NAME = '$tableName';
-
- /** the related Propel class for this table */
- const OM_CLASS = '$tablePhpName';
-
- /** A class that can be returned by this peer. */
- const CLASS_DEFAULT = '".$this->getStubObjectBuilder()->getClasspath()."';
-
- /** the related TableMap class for this table */
- const TM_CLASS = '".$this->getTableMapClass()."';
-
- /** The total number of columns. */
- const NUM_COLUMNS = ".$this->getTable()->getNumColumns().";
-
- /** The number of lazy-loaded columns. */
- const NUM_LAZY_LOAD_COLUMNS = ".$this->getTable()->getNumLazyLoadColumns().";
-
- /** The number of columns to hydrate (NUM_COLUMNS - NUM_LAZY_LOAD_COLUMNS) */
- const NUM_HYDRATE_COLUMNS = ". ($this->getTable()->getNumColumns() - $this->getTable()->getNumLazyLoadColumns()) .";
-";
$this->addColumnNameConstants($script);
$this->addInheritanceColumnConstants($script);
if ($this->getTable()->hasEnumColumns()) {
@@ -544,8 +508,8 @@ protected function addBuildTableMap(&$script)
*/
public static function buildTableMap()
{
- \$dbMap = Propel::getServiceContainer()->getDatabaseMap(static::DATABASE_NAME);
- if (!\$dbMap->hasTable(static::TABLE_NAME)) {
+ \$dbMap = Propel::getServiceContainer()->getDatabaseMap(" . $this->getTableMapClass() . "::DATABASE_NAME);
+ if (!\$dbMap->hasTable(" . $this->getTableMapClass() . "::TABLE_NAME)) {
\$dbMap->addTableObject(new ".$this->getTableMapClass()."());
}
}
@@ -606,12 +570,12 @@ protected function addAlias(&$script)
* \$c->addJoin(TablePeer::alias(\"alias1\", TablePeer::PRIMARY_KEY_COLUMN), TablePeer::PRIMARY_KEY_COLUMN);
* </code>
* @param string \$alias The alias for the current table.
- * @param string \$column The column name for current table. (i.e. ".$this->getPeerClassName(true)."::COLUMN_NAME).
+ * @param string \$column The column name for current table. (i.e. ".$this->getTableMapClass()."::COLUMN_NAME).
* @return string
*/
public static function alias(\$alias, \$column)
{
- return str_replace(static::TABLE_NAME.'.', \$alias.'.', \$column);
+ return str_replace(" . $this->getTableMapClass() . "::TABLE_NAME.'.', \$alias.'.', \$column);
}
";
}
@@ -682,7 +646,7 @@ public static function doCount(Criteria \$criteria, \$distinct = false, Connecti
// We need to set the primary table name, since in the case that there are no WHERE columns
// it will be impossible for the BasePeer::createSelectSql() method to determine which
// tables go into the FROM clause.
- \$criteria->setPrimaryTableName(static::TABLE_NAME);
+ \$criteria->setPrimaryTableName(" . $this->getTableMapClass() . "::TABLE_NAME);
if (\$distinct && !in_array(Criteria::DISTINCT, \$criteria->getSelectModifiers())) {
\$criteria->setDistinct();
@@ -693,10 +657,10 @@ public static function doCount(Criteria \$criteria, \$distinct = false, Connecti
}
\$criteria->clearOrderByColumns(); // ORDER BY won't ever affect the count
- \$criteria->setDbName(self::DATABASE_NAME); // Set the correct dbName
+ \$criteria->setDbName(" . $this->getTableMapClass() . "::DATABASE_NAME); // Set the correct dbName
if (null === \$con) {
- \$con = Propel::getServiceContainer()->getReadConnection(static::DATABASE_NAME);
+ \$con = Propel::getServiceContainer()->getReadConnection(" . $this->getTableMapClass() . "::DATABASE_NAME);
}";
// apply behaviors
@@ -791,7 +755,7 @@ protected function addDoSelectStmt(&$script)
public static function doSelectStmt(Criteria \$criteria, ConnectionInterface \$con = null)
{
if (null === \$con) {
- \$con = Propel::getServiceContainer()->getReadConnection(static::DATABASE_NAME);
+ \$con = Propel::getServiceContainer()->getReadConnection(" . $this->getTableMapClass() . "::DATABASE_NAME);
}
if (!\$criteria->hasSelectClause()) {
@@ -800,7 +764,7 @@ public static function doSelectStmt(Criteria \$criteria, ConnectionInterface \$c
}
// Set the correct dbName
- \$criteria->setDbName(self::DATABASE_NAME);";
+ \$criteria->setDbName(" . $this->getTableMapClass() . "::DATABASE_NAME);";
// apply behaviors
if ($this->hasBehaviorModifier('preSelect')) {
$this->applyBehaviorModifier('preSelect', $script);
@@ -1212,20 +1176,20 @@ public static function populateObject(\$row, \$startcol = 0)
// We no longer rehydrate the object, since this can cause data loss.
// See http://www.propelorm.org/ticket/509
// \$obj->hydrate(\$row, \$startcol, true); // rehydrate
- \$col = \$startcol + static::NUM_HYDRATE_COLUMNS;";
+ \$col = \$startcol + " . $this->getTableMapClass() . "::NUM_HYDRATE_COLUMNS;";
if ($table->isAbstract()) {
$script .= "
} elseif (null == \$key) {
// empty resultset, probably from a left join
// since this table is abstract, we can't hydrate an empty object
\$obj = null;
- \$col = \$startcol + static::NUM_HYDRATE_COLUMNS;";
+ \$col = \$startcol + " . $this->getTableMapClass() . "::NUM_HYDRATE_COLUMNS;";
}
$script .= "
} else {";
if (!$table->getChildrenColumn()) {
$script .= "
- \$cls = static::OM_CLASS;";
+ \$cls = " . $this->getTableMapClass() . "::OM_CLASS;";
} else {
$script .= "
\$cls = static::getOMClass(\$row, \$startcol, false);";
@@ -1323,7 +1287,7 @@ protected function addGetOMClass_NoInheritance(&$script)
*/
public static function getOMClass(\$withPrefix = true)
{
- return \$withPrefix ? static::CLASS_DEFAULT : static::OM_CLASS;
+ return \$withPrefix ? " . $this->getTableMapClass() . "::CLASS_DEFAULT : " . $this->getTableMapClass() . "::OM_CLASS;
}
";
}
@@ -1354,6 +1318,8 @@ protected function addGetOMClass_NoInheritance_Abstract(&$script)
protected function addDoInsert(&$script)
{
$table = $this->getTable();
+ $tableMapClass = $this->getTableMapClass();
+
$script .= "
/**
* Performs an INSERT on the database, given a ".$this->getObjectClassName()." or Criteria object.
@@ -1367,7 +1333,7 @@ protected function addDoInsert(&$script)
public static function doInsert(\$values, ConnectionInterface \$con = null)
{
if (null === \$con) {
- \$con = Propel::getServiceContainer()->getWriteConnection(static::DATABASE_NAME);
+ \$con = Propel::getServiceContainer()->getWriteConnection(" . $tableMapClass . "::DATABASE_NAME);
}
if (\$values instanceof Criteria) {
@@ -1408,10 +1374,11 @@ public static function doInsert(\$values, ConnectionInterface \$con = null)
";
}
}
+
$script .= "
// Set the correct dbName
- \$criteria->setDbName(self::DATABASE_NAME);
+ \$criteria->setDbName(" . $this->getTableMapClass() . "::DATABASE_NAME);
try {
// use transaction because \$criteria could contain info
@@ -1449,10 +1416,10 @@ protected function addDoUpdate(&$script)
public static function doUpdate(\$values, ConnectionInterface \$con = null)
{
if (null === \$con) {
- \$con = Propel::getServiceContainer()->getWriteConnection(static::DATABASE_NAME);
+ \$con = Propel::getServiceContainer()->getWriteConnection(" . $this->getTableMapClass() . "::DATABASE_NAME);
}
- \$selectCriteria = new Criteria(self::DATABASE_NAME);
+ \$selectCriteria = new Criteria(" . $this->getTableMapClass() . "::DATABASE_NAME);
if (\$values instanceof Criteria) {
\$criteria = clone \$values; // rename for clarity
@@ -1465,7 +1432,7 @@ public static function doUpdate(\$values, ConnectionInterface \$con = null)
if (\$value) {
\$selectCriteria->add(".$this->getColumnConstant($col).", \$value, \$comparison);
} else {
- \$selectCriteria->setPrimaryTableName(static::TABLE_NAME);
+ \$selectCriteria->setPrimaryTableName(" . $this->getTableMapClass() . "::TABLE_NAME);
}
";
} /* if col is prim key */
@@ -1478,7 +1445,7 @@ public static function doUpdate(\$values, ConnectionInterface \$con = null)
}
// set the correct dbName
- \$criteria->setDbName(self::DATABASE_NAME);
+ \$criteria->setDbName(" . $this->getTableMapClass() . "::DATABASE_NAME);
return {$this->basePeerClassName}::doUpdate(\$selectCriteria, \$criteria, \$con);
}
@@ -1502,7 +1469,7 @@ protected function addDoDeleteAll(&$script)
public static function doDeleteAll(ConnectionInterface \$con = null)
{
if (null === \$con) {
- \$con = Propel::getServiceContainer()->getWriteConnection(static::DATABASE_NAME);
+ \$con = Propel::getServiceContainer()->getWriteConnection(" . $this->getTableMapClass() . "::DATABASE_NAME);
}
\$affectedRows = 0; // initialize var to track total num of affected rows
try {
@@ -1511,26 +1478,27 @@ public static function doDeleteAll(ConnectionInterface \$con = null)
\$con->beginTransaction();
";
if ($this->isDeleteCascadeEmulationNeeded()) {
- $script .="\$affectedRows += static::doOnDeleteCascade(new Criteria(static::DATABASE_NAME), \$con);
+ $script .="\$affectedRows += static::doOnDeleteCascade(new Criteria(" . $this->getTableMapClass() . "::DATABASE_NAME), \$con);
";
}
if ($this->isDeleteSetNullEmulationNeeded()) {
- $script .= "static::doOnDeleteSetNull(new Criteria(static::DATABASE_NAME), \$con);
+ $script .= "static::doOnDeleteSetNull(new Criteria(" . $this->getTableMapClass() . "::DATABASE_NAME), \$con);
";
}
- $script .= "\$affectedRows += {$this->basePeerClassName}::doDeleteAll(static::TABLE_NAME, \$con, static::DATABASE_NAME);
+ $script .= "\$affectedRows += {$this->basePeerClassName}::doDeleteAll(" . $this->getTableMapClass() . "::TABLE_NAME, \$con, " . $this->getTableMapClass() . "::DATABASE_NAME);
// Because this db requires some delete cascade/set null emulation, we have to
// clear the cached instance *after* the emulation has happened (since
// instances get re-added by the select statement contained therein).
static::clearInstancePool();
static::clearRelatedInstancePool();
- \$con->commit();
- return \$affectedRows;
+ \$con->commit();
} catch (PropelException \$e) {
\$con->rollBack();
throw \$e;
}
+
+ return \$affectedRows;
}
";
}
@@ -1558,7 +1526,7 @@ protected function addDoDelete(&$script)
static public function doDelete(\$values, ConnectionInterface \$con = null)
{
if (null === \$con) {
- \$con = Propel::getServiceContainer()->getWriteConnection(static::DATABASE_NAME);
+ \$con = Propel::getServiceContainer()->getWriteConnection(" . $this->getTableMapClass() . "::DATABASE_NAME);
}
if (\$values instanceof Criteria) {";
@@ -1591,7 +1559,7 @@ static public function doDelete(\$values, ConnectionInterface \$con = null)
$script .= "
} else { // it's a primary key, or an array of pks";
$script .= "
- \$criteria = new Criteria(self::DATABASE_NAME);";
+ \$criteria = new Criteria(" . $this->getTableMapClass() . "::DATABASE_NAME);";
if (1 === count($table->getPrimaryKey())) {
$pkey = $table->getPrimaryKey();
@@ -1640,7 +1608,7 @@ static public function doDelete(\$values, ConnectionInterface \$con = null)
}
// Set the correct dbName
- \$criteria->setDbName(self::DATABASE_NAME);
+ \$criteria->setDbName(" . $this->getTableMapClass() . "::DATABASE_NAME);
\$affectedRows = 0; // initialize var to track total num of affected rows
@@ -1751,7 +1719,7 @@ protected static function doOnDeleteCascade(Criteria \$criteria, ConnectionInter
$script .= "
// delete related $fkClassName objects
- \$criteria = new Criteria(".$joinedTablePeerBuilder->getPeerClassName(true)."::DATABASE_NAME);
+ \$criteria = new Criteria(".$joinedTablePeerBuilder->getTableMapClass()."::DATABASE_NAME);
";
for ($x = 0, $xlen = count($columnNamesF); $x < $xlen; $x++) {
$columnFK = $tblFK->getColumn($columnNamesF[$x]);
@@ -1828,8 +1796,8 @@ protected static function doOnDeleteSetNull(Criteria \$criteria, ConnectionInter
$columnNamesL = $fk->getForeignColumns(); // should be same num as foreign
$script .= "
// set fkey col in related $fkClassName rows to NULL
- \$selectCriteria = new Criteria(static::DATABASE_NAME);
- \$updateValues = new Criteria(static::DATABASE_NAME);";
+ \$selectCriteria = new Criteria(" . $this->getTableMapClass() . "::DATABASE_NAME);
+ \$updateValues = new Criteria(" . $this->getTableMapClass() . "::DATABASE_NAME);";
for ($x = 0, $xlen = count($columnNamesF); $x < $xlen; $x++) {
$columnFK = $tblFK->getColumn($columnNamesF[$x]);
@@ -1879,10 +1847,10 @@ static public function ".$this->getRetrieveMethodName()."(\$pk, ConnectionInterf
}
if (null === \$con) {
- \$con = Propel::getServiceContainer()->getReadConnection(static::DATABASE_NAME);
+ \$con = Propel::getServiceContainer()->getReadConnection(" . $this->getTableMapClass() . "::DATABASE_NAME);
}
- \$criteria = new Criteria(static::DATABASE_NAME);
+ \$criteria = new Criteria(" . $this->getTableMapClass() . "::DATABASE_NAME);
\$criteria->add(".$this->getColumnConstant($col).", \$pk);
\$v = static::doSelect(\$criteria, \$con);
@@ -1911,14 +1879,14 @@ protected function addRetrieveByPKs_SinglePK(&$script)
static public function ".$this->getRetrieveMethodName()."s(\$pks, ConnectionInterface \$con = null)
{
if (null === \$con) {
- \$con = Propel::getServiceContainer()->getReadConnection(static::DATABASE_NAME);
+ \$con = Propel::getServiceContainer()->getReadConnection(" . $this->getTableMapClass() . "::DATABASE_NAME);
}
\$objs = null;
if (empty(\$pks)) {
\$objs = array();
} else {
- \$criteria = new Criteria(static::DATABASE_NAME);";
+ \$criteria = new Criteria(" . $this->getTableMapClass() . "::DATABASE_NAME);";
$k1 = $table->getPrimaryKey();
$script .= "
\$criteria->add(".$this->getColumnConstant($k1[0]).", \$pks, Criteria::IN);";
@@ -1969,9 +1937,9 @@ static public function ".$this->getRetrieveMethodName()."(";
}
if (null === \$con) {
- \$con = Propel::getServiceContainer()->getReadConnection(static::DATABASE_NAME);
+ \$con = Propel::getServiceContainer()->getReadConnection(" . $this->getTableMapClass() . "::DATABASE_NAME);
}
- \$criteria = new Criteria(static::DATABASE_NAME);";
+ \$criteria = new Criteria(" . $this->getTableMapClass() . "::DATABASE_NAME);";
foreach ($table->getPrimaryKey() as $col) {
$clo = strtolower($col->getName());
$script .= "
@@ -2000,7 +1968,7 @@ protected function addGetTableMap(&$script)
*/
public static function getTableMap()
{
- return Propel::getServiceContainer()->getDatabaseMap(self::DATABASE_NAME)->getTable(self::TABLE_NAME);
+ return Propel::getServiceContainer()->getDatabaseMap(" . $this->getTableMapClass() . "::DATABASE_NAME)->getTable(" . $this->getTableMapClass() . "::TABLE_NAME);
}
";
}
@@ -2151,11 +2119,11 @@ public static function doSelectJoin".$thisTableObjectBuilder->getFKPhpNameAffix(
// Set the correct dbName if it has not been overridden
if (\$criteria->getDbName() == Propel::getServiceContainer()->getDefaultDatasource()) {
- \$criteria->setDbName(self::DATABASE_NAME);
+ \$criteria->setDbName(" . $this->getTableMapClass() . "::DATABASE_NAME);
}
static::addSelectColumns(\$criteria);
- \$startcol = static::NUM_HYDRATE_COLUMNS;
+ \$startcol = " . $this->getTableMapClass() . "::NUM_HYDRATE_COLUMNS;
".$joinedTablePeerBuilder->getPeerClassName(true)."::addSelectColumns(\$criteria);
";
@@ -2283,7 +2251,7 @@ public static function doCountJoin".$thisTableObjectBuilder->getFKPhpNameAffix($
// We need to set the primary table name, since in the case that there are no WHERE columns
// it will be impossible for the BasePeer::createSelectSql() method to determine which
// tables go into the FROM clause.
- \$criteria->setPrimaryTableName(static::TABLE_NAME);
+ \$criteria->setPrimaryTableName(" . $this->getTableMapClass() . "::TABLE_NAME);
if (\$distinct && !in_array(Criteria::DISTINCT, \$criteria->getSelectModifiers())) {
\$criteria->setDistinct();
@@ -2296,10 +2264,10 @@ public static function doCountJoin".$thisTableObjectBuilder->getFKPhpNameAffix($
\$criteria->clearOrderByColumns(); // ORDER BY won't ever affect the count
// Set the correct dbName
- \$criteria->setDbName(self::DATABASE_NAME);
+ \$criteria->setDbName(" . $this->getTableMapClass() . "::DATABASE_NAME);
if (null === \$con) {
- \$con = Propel::getServiceContainer()->getReadConnection(static::DATABASE_NAME);
+ \$con = Propel::getServiceContainer()->getReadConnection(" . $this->getTableMapClass() . "::DATABASE_NAME);
}
";
$script .= $this->addCriteriaJoin($fk, $table, $joinTable, $joinedTablePeerBuilder);
@@ -2354,11 +2322,11 @@ public static function doSelectJoinAll(Criteria \$criteria, \$con = null, \$join
// Set the correct dbName if it has not been overridden
if (\$criteria->getDbName() == Propel::getServiceContainer()->getDefaultDatasource()) {
- \$criteria->setDbName(self::DATABASE_NAME);
+ \$criteria->setDbName(" . $this->getTableMapClass() . "::DATABASE_NAME);
}
static::addSelectColumns(\$criteria);
- \$startcol2 = static::NUM_HYDRATE_COLUMNS;
+ \$startcol2 = " . $this->getTableMapClass() . "::NUM_HYDRATE_COLUMNS;
";
$index = 2;
foreach ($table->getForeignKeys() as $fk) {
@@ -2371,10 +2339,11 @@ public static function doSelectJoinAll(Criteria \$criteria, \$con = null, \$join
$joinedTablePeerBuilder = $this->getNewPeerBuilder($joinTable);
$joinClassName = $joinedTablePeerBuilder->getObjectClassName();
+ $this->declareClass($joinedTablePeerBuilder->getTableMapBuilder()->getFullyQualifiedClassName());
$script .= "
".$joinedTablePeerBuilder->getPeerClassName(true)."::addSelectColumns(\$criteria);
- \$startcol$new_index = \$startcol$index + ".$joinedTablePeerBuilder->getPeerClassName(true)."::NUM_HYDRATE_COLUMNS;
+ \$startcol$new_index = \$startcol$index + ".$joinedTablePeerBuilder->getTableMapClass()."::NUM_HYDRATE_COLUMNS;
";
$index = $new_index;
@@ -2522,7 +2491,7 @@ public static function doCountJoinAll(Criteria \$criteria, \$distinct = false, C
// We need to set the primary table name, since in the case that there are no WHERE columns
// it will be impossible for the BasePeer::createSelectSql() method to determine which
// tables go into the FROM clause.
- \$criteria->setPrimaryTableName(static::TABLE_NAME);
+ \$criteria->setPrimaryTableName(" . $this->getTableMapClass() . "::TABLE_NAME);
if (\$distinct && !in_array(Criteria::DISTINCT, \$criteria->getSelectModifiers())) {
\$criteria->setDistinct();
@@ -2535,10 +2504,10 @@ public static function doCountJoinAll(Criteria \$criteria, \$distinct = false, C
\$criteria->clearOrderByColumns(); // ORDER BY won't ever affect the count
// Set the correct dbName
- \$criteria->setDbName(self::DATABASE_NAME);
+ \$criteria->setDbName(" . $this->getTableMapClass() . "::DATABASE_NAME);
if (null === \$con) {
- \$con = Propel::getServiceContainer()->getReadConnection(static::DATABASE_NAME);
+ \$con = Propel::getServiceContainer()->getReadConnection(" . $this->getTableMapClass() . "::DATABASE_NAME);
}
";
@@ -2614,11 +2583,11 @@ public static function doSelectJoinAllExcept".$thisTableObjectBuilder->getFKPhpN
// \$criteria->getDbName() will return the same object if not set to another value
// so == check is okay and faster
if (\$criteria->getDbName() == Propel::getServiceContainer()->getDefaultDatasource()) {
- \$criteria->setDbName(self::DATABASE_NAME);
+ \$criteria->setDbName(" . $this->getTableMapClass() . "::DATABASE_NAME);
}
static::addSelectColumns(\$criteria);
- \$startcol2 = static::NUM_HYDRATE_COLUMNS;
+ \$startcol2 = " . $this->getTableMapClass() . "::NUM_HYDRATE_COLUMNS;
";
$index = 2;
foreach ($table->getForeignKeys() as $subfk) {
@@ -2633,7 +2602,7 @@ public static function doSelectJoinAllExcept".$thisTableObjectBuilder->getFKPhpN
$new_index = $index + 1;
$script .= "
".$joinTablePeerBuilder->getPeerClassName(true)."::addSelectColumns(\$criteria);
- \$startcol$new_index = \$startcol$index + ".$joinTablePeerBuilder->getPeerClassName(true)."::NUM_HYDRATE_COLUMNS;
+ \$startcol$new_index = \$startcol$index + ".$joinTablePeerBuilder->getTableMapClass()."::NUM_HYDRATE_COLUMNS;
";
$index = $new_index;
} // if joinClassName not excludeClassName
@@ -2793,7 +2762,7 @@ public static function doCountJoinAllExcept".$thisTableObjectBuilder->getFKPhpNa
// We need to set the primary table name, since in the case that there are no WHERE columns
// it will be impossible for the BasePeer::createSelectSql() method to determine which
// tables go into the FROM clause.
- \$criteria->setPrimaryTableName(static::TABLE_NAME);
+ \$criteria->setPrimaryTableName(" . $this->getTableMapClass() . "::TABLE_NAME);
if (\$distinct && !in_array(Criteria::DISTINCT, \$criteria->getSelectModifiers())) {
\$criteria->setDistinct();
@@ -2806,10 +2775,10 @@ public static function doCountJoinAllExcept".$thisTableObjectBuilder->getFKPhpNa
\$criteria->clearOrderByColumns(); // ORDER BY should not affect count
// Set the correct dbName
- \$criteria->setDbName(self::DATABASE_NAME);
+ \$criteria->setDbName(" . $this->getTableMapClass() . "::DATABASE_NAME);
if (null === \$con) {
- \$con = Propel::getServiceContainer()->getReadConnection(static::DATABASE_NAME);
+ \$con = Propel::getServiceContainer()->getReadConnection(" . $this->getTableMapClass() . "::DATABASE_NAME);
}
";
View
3 src/Propel/Generator/Builder/Om/QueryBuilder.php
@@ -171,6 +171,7 @@ protected function addClassBody(&$script)
);
$this->declareClassFromBuilder($this->getStubQueryBuilder(), 'Child');
$this->declareClassFromBuilder($this->getStubPeerBuilder());
+ $this->declareClassFromBuilder($this->getTableMapBuilder());
// apply behaviors
$this->applyBehaviorModifier('queryAttributes', $script, " ");
@@ -415,7 +416,7 @@ public function findPk(\$key, \$con = null)
return \$obj;
}
if (\$con === null) {
- \$con = Propel::getServiceContainer()->getReadConnection({$peerClassName}::DATABASE_NAME);
+ \$con = Propel::getServiceContainer()->getReadConnection({$this->getTableMapClass()}::DATABASE_NAME);
}
\$this->basePreSelect(\$con);
if (\$this->formatter || \$this->modelAlias || \$this->with || \$this->select
View
26 src/Propel/Generator/Builder/Om/TableMapBuilder.php
@@ -97,7 +97,9 @@ protected function addClassBody(&$script)
'\Propel\Runtime\Map\TableMap',
'\Propel\Runtime\Map\RelationMap'
);
- $this->addConstants($script);
+
+ $script .= $this->addConstants();
+
$this->addAttributes($script);
$this->addInitialize($script);
$this->addBuildRelations($script);
@@ -106,16 +108,22 @@ protected function addClassBody(&$script)
/**
* Adds any constants needed for this TableMap class.
- * @param string &$script The script will be modified in this method.
+ *
+ * @return string
*/
- protected function addConstants(&$script)
+ protected function addConstants()
{
- $script .= "
- /**
- * The (dot-path) name of this class
- */
- const CLASS_NAME = '".$this->getClasspath()."';
-";
+ return $this->renderTemplate('tableMapConstants', array(
+ 'className' => $this->getClasspath(),
+ 'dbName' => $this->getDatabase()->getName(),
+ 'tableName' => $this->getTable()->getName(),
+ 'tablePhpName' => $this->getTable()->isAbstract() ? '' : addslashes($this->getStubObjectBuilder()->getFullyQualifiedClassName()),
+ 'classPath' => $this->getStubObjectBuilder()->getClasspath(),
+ 'nbColumns' => $this->getTable()->getNumColumns(),
+ 'nbLazyLoadColumns' => $this->getTable()->getNumLazyLoadColumns(),
+ 'nbHydrateColumns' => $this->getTable()->getNumColumns() - $this->getTable()->getNumLazyLoadColumns(),
+ 'peerClassName' => $this->getStubPeerBuilder()->getFullyQualifiedClassName(),
+ ));
}
/**
View
44 src/Propel/Generator/Builder/Om/templates/tableMapConstants.php
@@ -0,0 +1,44 @@
+ /**
+ * The (dot-path) name of this class
+ */
+ const CLASS_NAME = '<?php echo $className ?>';
+
+ /**
+ * The default database name for this class
+ */
+ const DATABASE_NAME = '<?php echo $dbName ?>';
+
+ /**
+ * The table name for this class
+ */
+ const TABLE_NAME = '<?php echo $tableName ?>';
+
+ /**
+ * The related Propel class for this table
+ */
+ const OM_CLASS = '<?php echo $tablePhpName ?>';
+
+ /**
+ * A class that can be returned by this peer
+ */
+ const CLASS_DEFAULT = '<?php echo $classPath ?>';
+
+ /**
+ * The related TableMap class for this table
+ */
+ const PEER_CLASS = '<?php echo $peerClassName ?>';
+
+ /**
+ * The total number of columns
+ */
+ const NUM_COLUMNS = <?php echo $nbColumns ?>;
+
+ /**
+ * The number of lazy-loaded columns
+ */
+ const NUM_LAZY_LOAD_COLUMNS = <?php echo $nbLazyLoadColumns ?>;
+
+ /**
+ * The number of columns to hydrate (NUM_COLUMNS - NUM_LAZY_LOAD_COLUMNS)
+ */
+ const NUM_HYDRATE_COLUMNS = <?php echo $nbHydrateColumns ?>;
View
16 src/Propel/Runtime/ActiveQuery/ModelCriteria.php
@@ -64,6 +64,8 @@ class ModelCriteria extends Criteria implements \IteratorAggregate
protected $modelPeerName;
+ protected $modelTableMapName;
+
protected $modelAlias;
protected $useAliasInSQL = false;
@@ -104,15 +106,17 @@ public function __construct($dbName = null, $modelName = null, $modelAlias = nul
{
$this->setDbName($dbName);
$this->originalDbName = $dbName;
+
if (0 === strpos($modelName, '\\')) {
$this->modelName = substr($modelName, 1);
} else {
$this->modelName = $modelName;
}
- $this->modelPeerName = constant($this->modelName . '::PEER');
- $this->modelAlias = $modelAlias;
- $this->tableMap = Propel::getServiceContainer()->getDatabaseMap($this->getDbName())->getTableByPhpName($this->modelName);
+ $this->modelTableMapName = constant($this->modelName . '::TABLE_MAP');
+ $this->modelPeerName = constant($this->modelTableMapName . '::PEER_CLASS');
+ $this->modelAlias = $modelAlias;
+ $this->tableMap = Propel::getServiceContainer()->getDatabaseMap($this->getDbName())->getTableByPhpName($this->modelName);
}
/**
@@ -586,7 +590,7 @@ protected function configureSelectColumns()
// it will be impossible for the BasePeer::createSelectSql() method to determine which
// tables go into the FROM clause.
if (!$this->selectQueries) {
- $this->setPrimaryTableName(constant($this->modelPeerName . '::TABLE_NAME'));
+ $this->setPrimaryTableName(constant($this->modelTableMapName . '::TABLE_NAME'));
}
// Add requested columns which are not withColumns
@@ -1496,7 +1500,7 @@ public function count($con = null)
// We need to set the primary table name, since in the case that there are no WHERE columns
// it will be impossible for the BasePeer::createSelectSql() method to determine which
// tables go into the FROM clause.
- $criteria->setPrimaryTableName(constant($this->modelPeerName.'::TABLE_NAME'));
+ $criteria->setPrimaryTableName(constant($this->modelTableMapName . '::TABLE_NAME'));
$stmt = $criteria->doCount($con);
if ($row = $stmt->fetch(\PDO::FETCH_NUM)) {
@@ -1759,7 +1763,7 @@ public function update($values, $con = null, $forceIndividualSaves = false)
}
$criteria = $this->isKeepQuery() ? clone $this : $this;
- $criteria->setPrimaryTableName(constant($this->modelPeerName.'::TABLE_NAME'));
+ $criteria->setPrimaryTableName(constant($this->modelTableMapName.'::TABLE_NAME'));
$con->beginTransaction();
try {
View
13 src/Propel/Runtime/Collection/Collection.php
@@ -484,6 +484,17 @@ public function getPeerClass()
return constant($this->getFullyQualifiedModel() . '::PEER');
}
+ public function getTableMapClass()
+ {
+ $model = $this->getModel();
+
+ if (empty($model)) {
+ throw new ModelNotFoundException('You must set the collection model before interacting with it');
+ }
+
+ return constant($this->getFullyQualifiedModel() . '::TABLE_MAP');
+ }
+
/**
* @param AbstractFormatter $formatter
*/
@@ -507,7 +518,7 @@ public function getFormatter()
*/
public function getWriteConnection()
{
- $databaseName = constant($this->getPeerClass() . '::DATABASE_NAME');
+ $databaseName = constant($this->getTableMapClass() . '::DATABASE_NAME');
return Propel::getServiceContainer()->getWriteConnection($databaseName);
}
View
3 ...Propel/Tests/Generator/Behavior/AggregateColumn/AggregateColumnBehaviorWithSchemaTest.php
@@ -17,6 +17,7 @@
use Propel\Tests\BookstoreSchemas\BookstoreContestQuery;
use Propel\Tests\BookstoreSchemas\BookstoreQuery;
use Propel\Tests\BookstoreSchemas\BookstorePeer;
+use Propel\Tests\BookstoreSchemas\Map\BookstoreTableMap;
use Propel\Tests\BookstoreSchemas\Customer;
use Propel\Tests\BookstoreSchemas\CustomerQuery;
use Propel\Tests\Helpers\Schemas\SchemasTestBase;
@@ -34,7 +35,7 @@ protected function setUp()
{
parent::setUp();
- $this->con = Propel::getServiceContainer()->getConnection(BookstorePeer::DATABASE_NAME);
+ $this->con = Propel::getServiceContainer()->getConnection(BookstoreTableMap::DATABASE_NAME);
$this->con->beginTransaction();
}
View
1 ...s/Propel/Tests/Generator/Behavior/ConcreteInheritance/ConcreteInheritanceBehaviorTest.php
@@ -35,7 +35,6 @@
* Tests for ConcreteInheritanceBehavior class
*
* @author François Zaniontto
- * @version $Revision$
*/
class ConcreteInheritanceBehaviorTest extends BookstoreTestBase
{
View
2 tests/Propel/Tests/Generator/Behavior/I18n/I18nBehaviorObjectBuilderModifierTest.php
@@ -14,10 +14,8 @@
use Propel\Tests\Bookstore\Behavior\Movie;
use Propel\Tests\Bookstore\Behavior\MovieQuery;
use Propel\Tests\Bookstore\Behavior\MovieI18nQuery;
-
use Propel\Generator\Util\QuickBuilder;
use Propel\Generator\Behavior\I18n\I18nBehavior;
-
use Propel\Runtime\Propel;
/**
View
2 tests/Propel/Tests/Generator/Builder/NamespaceTest.php
@@ -238,7 +238,7 @@ public function testManyToMany()
$this->assertEquals(1, $book2->countNamespacedBookClubs());
$nbRels = \Baz\NamespacedBookListRelQuery::create()->count();
$this->assertEquals(3, $nbRels);
- $con = Propel::getServiceContainer()->getConnection(\Baz\NamespacedBookListRelPeer::DATABASE_NAME);
+ $con = Propel::getServiceContainer()->getConnection(\Baz\Map\NamespacedBookListRelTableMap::DATABASE_NAME);
$books = \Foo\Bar\NamespacedBookQuery::create()
->orderByTitle()
->joinWith('NamespacedBookListRel')
View
6 tests/Propel/Tests/Generator/Builder/Om/GeneratedObjectLazyLoadTest.php
@@ -40,7 +40,7 @@ public function setUp()
public function testNormalColumnsRequireNoQueryOnGetter()
{
- $con = Propel::getServiceContainer()->getConnection(\LazyLoadActiveRecordPeer::DATABASE_NAME);
+ $con = Propel::getServiceContainer()->getConnection(\Map\LazyLoadActiveRecordTableMap::DATABASE_NAME);
$con->useDebug(true);
$obj = new \LazyLoadActiveRecord();
$obj->setFoo('hello');
@@ -54,7 +54,7 @@ public function testNormalColumnsRequireNoQueryOnGetter()
public function testLazyLoadedColumnsRequireAnAdditionalQueryOnGetter()
{
- $con = Propel::getServiceContainer()->getConnection(\LazyLoadActiveRecordPeer::DATABASE_NAME);
+ $con = Propel::getServiceContainer()->getConnection(\Map\LazyLoadActiveRecordTableMap::DATABASE_NAME);
$con->useDebug(true);
$obj = new \LazyLoadActiveRecord();
$obj->setBar('hello');
@@ -68,7 +68,7 @@ public function testLazyLoadedColumnsRequireAnAdditionalQueryOnGetter()
public function testLazyLoadedColumnsWithDefaultRequireAnAdditionalQueryOnGetter()
{
- $con = Propel::getServiceContainer()->getConnection(\LazyLoadActiveRecordPeer::DATABASE_NAME);
+ $con = Propel::getServiceContainer()->getConnection(\Map\LazyLoadActiveRecordTableMap::DATABASE_NAME);
$con->useDebug(true);
$obj = new \LazyLoadActiveRecord();
$obj->setBaz('hello');
View
5 tests/Propel/Tests/Generator/Builder/Om/GeneratedObjectRelTest.php
@@ -18,6 +18,7 @@
use Propel\Tests\Bookstore\Book;
use Propel\Tests\Bookstore\BookPeer;
use Propel\Tests\Bookstore\BookQuery;
+use Propel\Tests\Bookstore\Map\BookTableMap;
use Propel\Tests\Bookstore\Bookstore;
use Propel\Tests\Bookstore\BookClubList;
use Propel\Tests\Bookstore\BookClubListQuery;
@@ -366,7 +367,7 @@ public function testFKGetterUseInstancePool()
BookstoreDataPopulator::populate();
BookPeer::clearInstancePool();
AuthorPeer::clearInstancePool();
- $con = Propel::getServiceContainer()->getConnection(BookPeer::DATABASE_NAME);
+ $con = Propel::getServiceContainer()->getConnection(BookTableMap::DATABASE_NAME);
$author = AuthorPeer::doSelectOne(new Criteria(), $con);
// populate book instance pool
$books = $author->getBooks(null, $con);
@@ -381,7 +382,7 @@ public function testRefFKGetJoin()
BookPeer::clearInstancePool();
AuthorPeer::clearInstancePool();
PublisherPeer::clearInstancePool();
- $con = Propel::getServiceContainer()->getConnection(BookPeer::DATABASE_NAME);
+ $con = Propel::getServiceContainer()->getConnection(BookTableMap::DATABASE_NAME);
$author = AuthorPeer::doSelectOne(new Criteria(), $con);
// populate book instance pool
$books = $author->getBooksJoinPublisher(null, $con);
View
21 tests/Propel/Tests/Generator/Builder/Om/GeneratedObjectTest.php
@@ -18,11 +18,12 @@
use Propel\Tests\Bookstore\AcctAuditLog;
use Propel\Tests\Bookstore\AcctAuditLogPeer;
use Propel\Tests\Bookstore\Author;
-use Propel\Tests\Bookstore\AuthorPeer;
use Propel\Tests\Bookstore\AuthorQuery;
+use Propel\Tests\Bookstore\Map\AuthorTableMap;
use Propel\Tests\Bookstore\Book;
use Propel\Tests\Bookstore\BookQuery;
use Propel\Tests\Bookstore\BookPeer;
+use Propel\Tests\Bookstore\Map\BookTableMap;
use Propel\Tests\Bookstore\BookReader;
use Propel\Tests\Bookstore\BookOpinion;
use Propel\Tests\Bookstore\BookOpinionPeer;
@@ -39,8 +40,10 @@
use Propel\Tests\Bookstore\ReviewPeer;
use Propel\Tests\Bookstore\BookstoreEmployee;
use Propel\Tests\Bookstore\BookstoreEmployeePeer;
+use Propel\Tests\Bookstore\Map\BookstoreEmployeeTableMap;
use Propel\Tests\Bookstore\BookstoreEmployeeAccount;
use Propel\Tests\Bookstore\BookstoreEmployeeAccountPeer;
+use Propel\Tests\Bookstore\Map\BookstoreEmployeeAccountTableMap;
use Propel\Tests\Bookstore\BookstoreContestEntry;
use Propel\Tests\Bookstore\BookstoreSale;
use Propel\Tests\Helpers\Bookstore\BookstoreTestBase;
@@ -142,7 +145,7 @@ public function testDefaultValues()
*/
public function testDefaultExpressions()
{
- if (Propel::getServiceContainer()->getAdapter(BookstoreEmployeePeer::DATABASE_NAME) instanceof DBSqlite) {
+ if (Propel::getServiceContainer()->getAdapter(BookstoreEmployeeTableMap::DATABASE_NAME) instanceof DBSqlite) {
$this->markTestSkipped("Cannot test default expressions with SQLite");
}
BookstoreEmployeeAccountPeer::doDeleteAll();
@@ -187,7 +190,7 @@ public function testDefaultExpressions()
*/
public function testDefaultExpressions_ReloadOnInsert()
{
- if (Propel::getServiceContainer()->getAdapter(BookstoreEmployeePeer::DATABASE_NAME) instanceof DBSqlite) {
+ if (Propel::getServiceContainer()->getAdapter(BookstoreEmployeeTableMap::DATABASE_NAME) instanceof DBSqlite) {
$this->markTestSkipped("Cannot test default date expressions with SQLite");
}
@@ -227,7 +230,7 @@ public function testDefaultExpressions_ReloadOnInsert()
*/
public function testDefaultExpressions_ReloadOnInsert_Override()
{
- if (Propel::getServiceContainer()->getAdapter(BookstoreEmployeePeer::DATABASE_NAME) instanceof DBSqlite) {
+ if (Propel::getServiceContainer()->getAdapter(BookstoreEmployeeTableMap::DATABASE_NAME) instanceof DBSqlite) {
$this->markTestSkipped("Cannot test default date expressions with SQLite");
}
@@ -352,8 +355,8 @@ public function testObjectInstances_Fkeys()
$this->assertSame($pub1, $book->getPublisher());
// now change values behind the scenes
- $con = Propel::getServiceContainer()->getConnection(BookstoreEmployeeAccountPeer::DATABASE_NAME);
- $con->exec("UPDATE " . BookPeer::TABLE_NAME . " SET "
+ $con = Propel::getServiceContainer()->getConnection(BookstoreEmployeeAccountTableMap::DATABASE_NAME);
+ $con->exec("UPDATE " . BookTableMap::TABLE_NAME . " SET "
. " publisher_id = " . $pub2->getId()
. " WHERE id = " . $book->getId());
@@ -369,7 +372,7 @@ public function testObjectInstances_Fkeys()
// Now let's set it back, just to be double sure ...
- $con->exec("UPDATE " . BookPeer::TABLE_NAME . " SET "
+ $con->exec("UPDATE " . BookTableMap::TABLE_NAME . " SET "
. " publisher_id = " . $pub1->getId()
. " WHERE id = " . $book->getId());
@@ -973,7 +976,7 @@ public function testPreSave()
public function testPreSaveFalse()
{
- $con = Propel::getServiceContainer()->getConnection(AuthorPeer::DATABASE_NAME);
+ $con = Propel::getServiceContainer()->getConnection(AuthorTableMap::DATABASE_NAME);
$author = new TestAuthorSaveFalse();
$author->setFirstName("bogus");
$author->setLastName("Lastname");
@@ -1006,7 +1009,7 @@ public function testPreDelete()
public function testPreDeleteFalse()
{
- $con = Propel::getServiceContainer()->getConnection(AuthorPeer::DATABASE_NAME);
+ $con = Propel::getServiceContainer()->getConnection(AuthorTableMap::DATABASE_NAME);
$author = new TestAuthorDeleteFalse();
$author->setFirstName("bogus");
$author->setLastName("Lastname");
View
14 tests/Propel/Tests/Generator/Builder/Om/GeneratedPeerDoDeleteTest.php
@@ -16,9 +16,11 @@
use Propel\Tests\Bookstore\AuthorPeer;
use Propel\Tests\Bookstore\Book;
use Propel\Tests\Bookstore\BookPeer;
+use Propel\Tests\Bookstore\Map\BookTableMap;
use Propel\Tests\Bookstore\BookOpinion;
use Propel\Tests\Bookstore\BookReader;
use Propel\Tests\Bookstore\BookReaderPeer;
+use Propel\Tests\Bookstore\Map\BookReaderTableMap;
use Propel\Tests\Bookstore\Bookstore;
use Propel\Tests\Bookstore\BookstoreContest;
use Propel\Tests\Bookstore\BookstoreContestPeer;
@@ -335,7 +337,7 @@ public function testDoDeleteAll_SetNull()
*/
public function testDoDeleteCompositePK()
{
- $con = Propel::getServiceContainer()->getConnection(BookPeer::DATABASE_NAME);
+ $con = Propel::getServiceContainer()->getConnection(BookTableMap::DATABASE_NAME);
ReaderFavoritePeer::doDeleteAll();
// Create books with IDs 1 to 3
@@ -507,7 +509,7 @@ public function testDoCountJoin()
*/
public function testDoCountJoinWithOrderBy()
{
- $c = new Criteria(BookPeer::DATABASE_NAME);
+ $c = new Criteria(BookTableMap::DATABASE_NAME);
$c->addAscendingOrderByColumn(BookPeer::ID);
// None of these should not throw an exception!
@@ -534,13 +536,13 @@ public function testRemoveInstanceFromPool_Null()
*/
private function createBookWithId($id)
{
- $con = Propel::getServiceContainer()->getConnection(BookPeer::DATABASE_NAME);
+ $con = Propel::getServiceContainer()->getConnection(BookTableMap::DATABASE_NAME);
$b = BookPeer::retrieveByPK($id);
if (!$b) {
$b = new Book();
$b->setTitle("Book$id")->setISBN("BookISBN$id")->save();
$b1Id = $b->getId();
- $sql = "UPDATE " . BookPeer::TABLE_NAME . " SET id = ? WHERE id = ?";
+ $sql = "UPDATE " . BookTableMap::TABLE_NAME . " SET id = ? WHERE id = ?";
$stmt = $con->prepare($sql);
$stmt->bindValue(1, $id);
$stmt->bindValue(2, $b1Id);
@@ -553,13 +555,13 @@ private function createBookWithId($id)
*/
private function createReaderWithId($id)
{
- $con = Propel::getServiceContainer()->getConnection(BookReaderPeer::DATABASE_NAME);
+ $con = Propel::getServiceContainer()->getConnection(BookReaderTableMap::DATABASE_NAME);
$r = BookReaderPeer::retrieveByPK($id);
if (!$r) {
$r = new BookReader();
$r->setName('Reader'.$id)->save();
$r1Id = $r->getId();
- $sql = "UPDATE " . BookReaderPeer::TABLE_NAME . " SET id = ? WHERE id = ?";
+ $sql = "UPDATE " . BookReaderTableMap::TABLE_NAME . " SET id = ? WHERE id = ?";
$stmt = $con->prepare($sql);
$stmt->bindValue(1, $id);
$stmt->bindValue(2, $r1Id);
View
9 tests/Propel/Tests/Generator/Builder/Om/GeneratedPeerDoSelectTest.php
@@ -19,11 +19,13 @@
use Propel\Tests\Bookstore\AuthorPeer;
use Propel\Tests\Bookstore\Book;
use Propel\Tests\Bookstore\BookPeer;
+use Propel\Tests\Bookstore\Map\BookTableMap;
use Propel\Tests\Bookstore\Bookstore;
use Propel\Tests\Bookstore\BookstoreEmployee;
use Propel\Tests\Bookstore\BookstoreEmployeePeer;
use Propel\Tests\Bookstore\BookstoreEmployeeAccount;
use Propel\Tests\Bookstore\BookstoreEmployeeAccountPeer;
+use Propel\Tests\Bookstore\Map\BookstoreEmployeeAccountTableMap;
use Propel\Tests\Bookstore\BookstoreCashier;
use Propel\Tests\Bookstore\BookstoreManager;
use Propel\Tests\Bookstore\BookOpinion;
@@ -36,6 +38,7 @@
use Propel\Tests\Bookstore\Customer;
use Propel\Tests\Bookstore\ReaderFavorite;
use Propel\Tests\Bookstore\ReaderFavoritePeer;
+use Propel\Tests\Bookstore\Map\ReaderFavoriteTableMap;
use Propel\Tests\Helpers\Bookstore\BookstoreEmptyTestBase;
use Propel\Tests\Helpers\Bookstore\BookstoreDataPopulator;
@@ -173,7 +176,7 @@ public function testDoSelectJoin_NullFk()
public function testDoSelectJoinOneToOne()
{
- $con = Propel::getServiceContainer()->getReadConnection(BookstoreEmployeeAccountPeer::DATABASE_NAME);
+ $con = Propel::getServiceContainer()->getReadConnection(BookstoreEmployeeAccountTableMap::DATABASE_NAME);
$count = $con->getQueryCount();
Propel::disableInstancePooling();
$c = new Criteria();
@@ -342,7 +345,7 @@ public function testHydrationJoinLazyLoad()
*/
public function testMultiColFk()
{
- $con = Propel::getServiceContainer()->getConnection(BookPeer::DATABASE_NAME);
+ $con = Propel::getServiceContainer()->getConnection(BookTableMap::DATABASE_NAME);
ReaderFavoritePeer::doDeleteAll();
@@ -367,7 +370,7 @@ public function testMultiColFk()
$rf1->setBookId($b1->getId());
$rf1->save();
- $c = new Criteria(ReaderFavoritePeer::DATABASE_NAME);
+ $c = new Criteria(ReaderFavoriteTableMap::DATABASE_NAME);
$c->add(ReaderFavoritePeer::BOOK_ID, $b1->getId());
$c->add(ReaderFavoritePeer::READER_ID, $r1->getId());
View
2 tests/Propel/Tests/Generator/Builder/Om/GeneratedPeerLazyLoadTest.php
@@ -39,7 +39,7 @@ public function setUp()
public function testNumHydrateColumns()
{
- $this->assertEquals(3, \LazyLoadActiveRecord2Peer::NUM_HYDRATE_COLUMNS);
+ $this->assertEquals(3, \Map\LazyLoadActiveRecord2TableMap::NUM_HYDRATE_COLUMNS);
}
public function testPopulateObjectNotInPool()
View
10 tests/Propel/Tests/Generator/Builder/Om/QueryBuilderTest.php
@@ -19,9 +19,11 @@
use Propel\Runtime\Util\BasePeer;
use Propel\Tests\Bookstore\AuthorPeer;
use Propel\Tests\Bookstore\AuthorQuery;
+use Propel\Tests\Bookstore\Map\AuthorTableMap;
use Propel\Tests\Bookstore\Book;
use Propel\Tests\Bookstore\BookPeer;
use Propel\Tests\Bookstore\BookQuery;
+use Propel\Tests\Bookstore\Map\BookTableMap;
use Propel\Tests\Bookstore\BookstoreEmployeeAccountPeer;
use Propel\Tests\Bookstore\BookstoreEmployeeAccountQuery;
use Propel\Tests\Bookstore\BookClubListQuery;
@@ -925,7 +927,7 @@ public function testUseFkQueryAlias()
$join->setRelationMap(BookPeer::getTableMap()->getRelation('Author'), null, 'a');
$join->setRelationAlias('a');
$q1 = BookQuery::create()
- ->addAlias('a', AuthorPeer::TABLE_NAME)
+ ->addAlias('a', AuthorTableMap::TABLE_NAME)
->addJoinObject($join, 'a')
->add('a.FIRST_NAME', 'Leo', Criteria::EQUAL);
$this->assertTrue($q->equals($q1), 'useFkQuery() uses the first argument as a table alias');
@@ -981,10 +983,10 @@ public function testUseFkQueryTwiceTwoAliases()
$join2->setRelationMap(BookPeer::getTableMap()->getRelation('Author'), null, 'b');
$join2->setRelationAlias('b');
$q1 = BookQuery::create()
- ->addAlias('a', AuthorPeer::TABLE_NAME)
+ ->addAlias('a', AuthorTableMap::TABLE_NAME)
->addJoinObject($join1, 'a')
->add('a.FIRST_NAME', 'Leo', Criteria::EQUAL)
- ->addAlias('b', AuthorPeer::TABLE_NAME)
+ ->addAlias('b', AuthorTableMap::TABLE_NAME)
->addJoinObject($join2, 'b')
->add('b.LAST_NAME', 'Tolstoi', Criteria::EQUAL);
$this->assertTrue($q->equals($q1), 'useFkQuery() called twice on the same relation with two aliases creates two joins');
@@ -1031,7 +1033,7 @@ public function testUseFkQueryTwoRelations()
public function testUseFkQueryNoAliasThenWith()
{
- $con = Propel::getServiceContainer()->getReadConnection(BookPeer::DATABASE_NAME);
+ $con = Propel::getServiceContainer()->getReadConnection(BookTableMap::DATABASE_NAME);
$books = BookQuery::create()
->useAuthorQuery()
->filterByFirstName('Leo')
View
8 tests/Propel/Tests/Generator/Builder/Om/TableMapBuilderTest.php
@@ -10,17 +10,15 @@
namespace Propel\Tests\Generator\Builder\Om;
-use Propel\Tests\Helpers\Bookstore\BookstoreTestBase;
-use Propel\Tests\Bookstore\Behavior\Table1Peer;
-
use Propel\Runtime\Propel;
use Propel\Runtime\Map\RelationMap;
+use Propel\Tests\Helpers\Bookstore\BookstoreTestBase;
+use Propel\Tests\Bookstore\Behavior\Map\Table1TableMap;
/**
* Test class for TableMapBuilder.
*
* @author François Zaninotto
- * @version $Id$
*/
class TableMapBuilderTest extends BookstoreTestBase
{
@@ -137,7 +135,7 @@ public function testBehaviors()
{
$bookTable = $this->databaseMap->getTableByPhpName('Propel\Tests\Bookstore\Book');
$this->assertEquals($bookTable->getBehaviors(), array(), 'getBehaviors() returns an empty array when no behaviors are registered');
- $tmap = Propel::getServiceContainer()->getDatabaseMap(Table1Peer::DATABASE_NAME)->getTable(Table1Peer::TABLE_NAME);
+ $tmap = Propel::getServiceContainer()->getDatabaseMap(Table1TableMap::DATABASE_NAME)->getTable(Table1TableMap::TABLE_NAME);
$expectedBehaviorParams = array('timestampable' => array('create_column' => 'created_on', 'update_column' => 'updated_on'));
$this->assertEquals($tmap->getBehaviors(), $expectedBehaviorParams, 'The map builder creates a getBehaviors() method to retrieve behaviors parameters when behaviors are registered');
}
View
7 tests/Propel/Tests/Helpers/Bookstore/BookstoreDataPopulator.php
@@ -18,6 +18,7 @@
use Propel\Tests\Bookstore\AuthorPeer;
use Propel\Tests\Bookstore\Book;
use Propel\Tests\Bookstore\BookPeer;
+use Propel\Tests\Bookstore\Map\BookTableMap;
use Propel\Tests\Bookstore\BookClubList;
use Propel\Tests\Bookstore\BookClubListPeer;
use Propel\Tests\Bookstore\BookListRel;
@@ -62,7 +63,7 @@ class BookstoreDataPopulator
public static function populate($con = null)
{
if ($con === null) {
- $con = Propel::getServiceContainer()->getConnection(BookPeer::DATABASE_NAME);
+ $con = Propel::getServiceContainer()->getConnection(BookTableMap::DATABASE_NAME);
}
$con->beginTransaction();
@@ -270,7 +271,7 @@ public static function populate($con = null)
public static function populateOpinionFavorite($con = null)
{
if ($con === null) {
- $con = Propel::getServiceContainer()->getConnection(BookPeer::DATABASE_NAME);
+ $con = Propel::getServiceContainer()->getConnection(BookTableMap::DATABASE_NAME);
}
$con->beginTransaction();
@@ -323,7 +324,7 @@ public static function depopulate($con = null)
}
// delete records from the database
if ($con === null) {
- $con = Propel::getServiceContainer()->getConnection(BookPeer::DATABASE_NAME);
+ $con = Propel::getServiceContainer()->getConnection(BookTableMap::DATABASE_NAME);
}
$con->beginTransaction();
foreach ($peerClasses as $peerClass) {
View
5 tests/Propel/Tests/Helpers/Bookstore/BookstoreTestBase.php
@@ -11,8 +11,7 @@
namespace Propel\Tests\Helpers\Bookstore;
use Propel\Runtime\Propel;
-
-use Propel\Tests\Bookstore\BookPeer;
+use Propel\Tests\Bookstore\Map\BookTableMap;
/**
* Base class contains some methods shared by subclass test cases.
@@ -50,7 +49,7 @@ protected function setUp()
about the implications of using a SET NAMES statement in the "queries" setting.');
}
}
- $this->con = Propel::getServiceContainer()->getConnection(BookPeer::DATABASE_NAME);
+ $this->con = Propel::getServiceContainer()->getConnection(BookTableMap::DATABASE_NAME);
$this->con->beginTransaction();
}
View
21 tests/Propel/Tests/Runtime/ActiveQuery/CriteriaMergeTest.php
@@ -13,8 +13,9 @@
use Propel\Tests\Helpers\Bookstore\BookstoreTestBase;
use Propel\Tests\Bookstore\AuthorPeer;
use Propel\Tests\Bookstore\BookPeer;
+use Propel\Tests\Bookstore\Map\AuthorTableMap;
+use Propel\Tests\Bookstore\Map\BookTableMap;
use Propel\Tests\Bookstore\PublisherPeer;
-
use Propel\Runtime\ActiveQuery\Criteria;
use Propel\Runtime\Util\BasePeer;
@@ -372,21 +373,21 @@ public function testMergeWithHavingConditions()
public function testMergeWithAliases()
{
$c1 = new Criteria();
- $c1->addAlias('b', BookPeer::TABLE_NAME);
+ $c1->addAlias('b', BookTableMap::TABLE_NAME);
$c2 = new Criteria();
$c1->mergeWith($c2);
- $this->assertEquals(array('b' => BookPeer::TABLE_NAME), $c1->getAliases(), 'mergeWith() does not remove an existing alias');
+ $this->assertEquals(array('b' => BookTableMap::TABLE_NAME), $c1->getAliases(), 'mergeWith() does not remove an existing alias');
$c1 = new Criteria();
$c2 = new Criteria();
- $c2->addAlias('a', AuthorPeer::TABLE_NAME);
+ $c2->addAlias('a', AuthorTableMap::TABLE_NAME);
$c1->mergeWith($c2);
- $this->assertEquals(array('a' => AuthorPeer::TABLE_NAME), $c1->getAliases(), 'mergeWith() merge aliases to an empty alias');
+ $this->assertEquals(array('a' => AuthorTableMap::TABLE_NAME), $c1->getAliases(), 'mergeWith() merge aliases to an empty alias');
$c1 = new Criteria();
- $c1->addAlias('b', BookPeer::TABLE_NAME);
+ $c1->addAlias('b', BookTableMap::TABLE_NAME);
$c2 = new Criteria();
- $c2->addAlias('a', AuthorPeer::TABLE_NAME);
+ $c2->addAlias('a', AuthorTableMap::TABLE_NAME);
$c1->mergeWith($c2);
- $this->assertEquals(array('b' => BookPeer::TABLE_NAME, 'a' => AuthorPeer::TABLE_NAME), $c1->getAliases(), 'mergeWith() merge aliases to an existing alias');
+ $this->assertEquals(array('b' => BookTableMap::TABLE_NAME, 'a' => AuthorTableMap::TABLE_NAME), $c1->getAliases(), 'mergeWith() merge aliases to an existing alias');
}
/**
@@ -395,9 +396,9 @@ public function testMergeWithAliases()
public function testMergeWithAliasesThrowsException()
{
$c1 = new Criteria();
- $c1->addAlias('b', BookPeer::TABLE_NAME);
+ $c1->addAlias('b', BookTableMap::TABLE_NAME);
$c2 = new Criteria();
- $c2->addAlias('b', AuthorPeer::TABLE_NAME);
+ $c2->addAlias('b', AuthorTableMap::TABLE_NAME);
$c1->mergeWith($c2);
}
View
71 tests/Propel/Tests/Runtime/ActiveQuery/ModelCriteriaTest.php
@@ -18,6 +18,7 @@
use Propel\Tests\Bookstore\AuthorQuery;
use Propel\Tests\Bookstore\Book;
use Propel\Tests\Bookstore\BookPeer;
+use Propel\Tests\Bookstore\Map\BookTableMap;
use Propel\Tests\Bookstore\BookQuery;
use Propel\Tests\Bookstore\Book2;
use Propel\Tests\Bookstore\Book2Query;
@@ -860,7 +861,7 @@ public function testJoin()
public function testJoinQuery()
{
- $con = Propel::getServiceContainer()->getConnection(BookPeer::DATABASE_NAME);
+ $con = Propel::getServiceContainer()->getConnection(BookTableMap::DATABASE_NAME);
BookstoreDataPopulator::depopulate($con);
BookstoreDataPopulator::populate($con);
@@ -990,7 +991,7 @@ public function testJoinAlias()
$params = array();
$this->assertCriteriaTranslation($c, $sql, $params, 'join() supports relation alias on main alias');
- $con = Propel::getServiceContainer()->getConnection(BookPeer::DATABASE_NAME);
+ $con = Propel::getServiceContainer()->getConnection(BookTableMap::DATABASE_NAME);
$c = new ModelCriteria('bookstore', 'Propel\Tests\Bookstore\Book', 'b');
$c->join('b.Author a');
$c->where('a.FirstName = ?', 'Leo');
@@ -1043,7 +1044,7 @@ public function testJoinOnSameTable()
public function testJoinAliasQuery()
{
- $con = Propel::getServiceContainer()->getConnection(BookPeer::DATABASE_NAME);
+ $con = Propel::getServiceContainer()->getConnection(BookTableMap::DATABASE_NAME);
$c = new ModelCriteria('bookstore', 'Propel\Tests\Bookstore\Book', 'b');
$c->join('b.Author a');
$c->where('a.FirstName = ?', 'Leo');
@@ -1062,7 +1063,7 @@ public function testJoinAliasQuery()
public function testAddJoinConditionSimple()
{
- $con = Propel::getServiceContainer()->getConnection(BookPeer::DATABASE_NAME);
+ $con = Propel::getServiceContainer()->getConnection(BookTableMap::DATABASE_NAME);
$c = new ModelCriteria('bookstore', 'Propel\Tests\Bookstore\Book');
$c->join('Propel\Tests\Bookstore\Book.Author', Criteria::INNER_JOIN);
$c->addJoinCondition('Author', 'Propel\Tests\Bookstore\Book.Title IS NOT NULL');
@@ -1073,7 +1074,7 @@ public function testAddJoinConditionSimple()
public function testAddJoinConditionBinding()
{
- $con = Propel::getServiceContainer()->getConnection(BookPeer::DATABASE_NAME);
+ $con = Propel::getServiceContainer()->getConnection(BookTableMap::DATABASE_NAME);
$c = new ModelCriteria('bookstore', 'Propel\Tests\Bookstore\Book');
$c->join('Propel\Tests\Bookstore\Book.Author', Criteria::INNER_JOIN);
$c->addJoinCondition('Author', 'Propel\Tests\Bookstore\Book.Title = ?', 'foo');
@@ -1084,7 +1085,7 @@ public function testAddJoinConditionBinding()
public function testAddJoinConditionSeveral()
{
- $con = Propel::getServiceContainer()->getConnection(BookPeer::DATABASE_NAME);
+ $con = Propel::getServiceContainer()->getConnection(BookTableMap::DATABASE_NAME);
$c = new ModelCriteria('bookstore', 'Propel\Tests\Bookstore\Book');
$c->join('Propel\Tests\Bookstore\Book.Author', Criteria::INNER_JOIN);
$c->addJoinCondition('Author', 'Propel\Tests\Bookstore\Book.Title = ?', 'foo');
@@ -1096,7 +1097,7 @@ public function testAddJoinConditionSeveral()
public function testAddJoinConditionBindingAndWhere()
{
- $con = Propel::getServiceContainer()->getConnection(BookPeer::DATABASE_NAME);
+ $con = Propel::getServiceContainer()->getConnection(BookTableMap::DATABASE_NAME);
$c = new ModelCriteria('bookstore', 'Propel\Tests\Bookstore\Book');
$c->where('Propel\Tests\Bookstore\Book.Title LIKE ?', 'foo%');
$c->join('Propel\Tests\Bookstore\Book.Author', Criteria::INNER_JOIN);
@@ -1108,7 +1109,7 @@ public function testAddJoinConditionBindingAndWhere()
public function testAddJoinConditionAlias()
{
- $con = Propel::getServiceContainer()->getConnection(BookPeer::DATABASE_NAME);
+ $con = Propel::getServiceContainer()->getConnection(BookTableMap::DATABASE_NAME);
$c = new ModelCriteria('bookstore', 'Propel\Tests\Bookstore\Book');
$c->join('Propel\Tests\Bookstore\Book.Author a', Criteria::INNER_JOIN);
$c->addJoinCondition('a', 'Book.Title IS NOT NULL');
@@ -1119,7 +1120,7 @@ public function testAddJoinConditionAlias()
public function testAddJoinConditionOperator()
{
- $con = Propel::getServiceContainer()->getConnection(BookPeer::DATABASE_NAME);
+ $con = Propel::getServiceContainer()->getConnection(BookTableMap::DATABASE_NAME);
$c = new ModelCriteria('bookstore', 'Propel\Tests\Bookstore\Book');
$c->join('Propel\Tests\Bookstore\Book.Author', Criteria::INNER_JOIN);
$c->addJoinCondition('Author', 'Propel\Tests\Bookstore\Book.Title IS NOT NULL', null, Criteria::LOGICAL_OR);
@@ -1130,7 +1131,7 @@ public function testAddJoinConditionOperator()
public function testSetJoinConditionCriterion()
{
- $con = Propel::getServiceContainer()->getConnection(BookPeer::DATABASE_NAME);
+ $con = Propel::getServiceContainer()->getConnection(BookTableMap::DATABASE_NAME);
$c = new ModelCriteria('bookstore', 'Propel\Tests\Bookstore\Book');
$c->join('Propel\Tests\Bookstore\Book.Author', Criteria::INNER_JOIN);
$criterion = $c->getNewCriterion(BookPeer::TITLE, BookPeer::TITLE . ' = ' . AuthorPeer::FIRST_NAME, Criteria::CUSTOM);
@@ -1142,7 +1143,7 @@ public function testSetJoinConditionCriterion()
public function testSetJoinConditionNamedCondition()
{
- $con = Propel::getServiceContainer()->getConnection(BookPeer::DATABASE_NAME);
+ $con = Propel::getServiceContainer()->getConnection(BookTableMap::DATABASE_NAME);
$c = new ModelCriteria('bookstore', 'Propel\Tests\Bookstore\Book');
$c->join('Propel\Tests\Bookstore\Book.Author', Criteria::INNER_JOIN);
$c->condition('cond1', 'Propel\Tests\Bookstore\Book.Title = Author.FirstName');
@@ -1593,7 +1594,7 @@ public function testFind()
public function testFindAddsSelectColumns()
{
- $con = Propel::getServiceContainer()->getConnection(BookPeer::DATABASE_NAME);
+ $con = Propel::getServiceContainer()->getConnection(BookTableMap::DATABASE_NAME);
$c = new ModelCriteria('bookstore', 'Propel\Tests\Bookstore\Book');
$books = $c->find($con);
$sql = "SELECT book.ID, book.TITLE, book.ISBN, book.PRICE, book.PUBLISHER_ID, book.AUTHOR_ID FROM `book`";
@@ -1602,7 +1603,7 @@ public function testFindAddsSelectColumns()
public function testFindTrueAliasAddsSelectColumns()
{
- $con = Propel::getServiceContainer()->getConnection(BookPeer::DATABASE_NAME);
+ $con = Propel::getServiceContainer()->getConnection(BookTableMap::DATABASE_NAME);
$c = new ModelCriteria('bookstore', 'Propel\Tests\Bookstore\Book');
$c->setModelAlias('b', true);
$books = $c->find($con);
@@ -1682,7 +1683,7 @@ public function testFindOneOrCreateThrowsExceptionWhenQueryContainsJoin()
public function testFindOneOrCreateMakesOneQueryWhenRecordNotExists()
{
- $con = Propel::getServiceContainer()->getConnection(BookPeer::DATABASE_NAME);
+ $con = Propel::getServiceContainer()->getConnection(BookTableMap::DATABASE_NAME);
BookQuery::create()->deleteAll($con);
$count = $con->getQueryCount();
$book = BookQuery::create('b')
@@ -1693,7 +1694,7 @@ public function testFindOneOrCreateMakesOneQueryWhenRecordNotExists()
public function testFindOneOrCreateMakesOneQueryWhenRecordExists()
{
- $con = Propel::getServiceContainer()->getConnection(BookPeer::DATABASE_NAME);
+ $con = Propel::getServiceContainer()->getConnection(BookTableMap::DATABASE_NAME);
BookQuery::create()->deleteAll($con);
$book = new Book();
$book->setPrice(125);
@@ -1845,7 +1846,7 @@ public function testFindBy()
$this->assertTrue(true, 'findBy() throws an exception when called on an unknown column name');
}
- $con = Propel::getServiceContainer()->getConnection(BookPeer::DATABASE_NAME);
+ $con = Propel::getServiceContainer()->getConnection(BookTableMap::DATABASE_NAME);
$c = new ModelCriteria('bookstore', 'Propel\Tests\Bookstore\Book');
$books = $c->findBy('Title', 'Don Juan', $con);
$expectedSQL = "SELECT book.ID, book.TITLE, book.ISBN, book.PRICE, book.PUBLISHER_ID, book.AUTHOR_ID FROM `book` WHERE book.TITLE='Don Juan'";
@@ -1859,7 +1860,7 @@ public function testFindBy()
public function testFindByArray()
{
- $con = Propel::getServiceContainer()->getConnection(BookPeer::DATABASE_NAME);
+ $con = Propel::getServiceContainer()->getConnection(BookTableMap::DATABASE_NAME);
$c = new ModelCriteria('bookstore', 'Propel\Tests\Bookstore\Book');
$books = $c->findByArray(array('Title' => 'Don Juan', 'ISBN' => 12345), $con);
$expectedSQL = "SELECT book.ID, book.TITLE, book.ISBN, book.PRICE, book.PUBLISHER_ID, book.AUTHOR_ID FROM `book` WHERE book.TITLE='Don Juan' AND book.ISBN=12345";
@@ -1876,7 +1877,7 @@ public function testFindOneBy()
$this->assertTrue(true, 'findOneBy() throws an exception when called on an unknown column name');
}
- $con = Propel::getServiceContainer()->getConnection(BookPeer::DATABASE_NAME);
+ $con = Propel::getServiceContainer()->getConnection(BookTableMap::DATABASE_NAME);
$c = new ModelCriteria('bookstore', 'Propel\Tests\Bookstore\Book');
$book = $c->findOneBy('Title', 'Don Juan', $con);
$expectedSQL = "SELECT book.ID, book.TITLE, book.ISBN, book.PRICE, book.PUBLISHER_ID, book.AUTHOR_ID FROM `book` WHERE book.TITLE='Don Juan' LIMIT 1";
@@ -1887,7 +1888,7 @@ public function testFindOneBy()
public function testFindOneByArray()
{
- $con = Propel::getServiceContainer()->getConnection(BookPeer::DATABASE_NAME);
+ $con = Propel::getServiceContainer()->getConnection(BookTableMap::DATABASE_NAME);
$c = new ModelCriteria('bookstore', 'Propel\Tests\Bookstore\Book');
$book = $c->findOneByArray(array('Title' => 'Don Juan', 'ISBN' => 12345), $con);
$expectedSQL = "SELECT book.ID, book.TITLE, book.ISBN, book.PRICE, book.PUBLISHER_ID, book.AUTHOR_ID FROM `book` WHERE book.TITLE='Don Juan' AND book.ISBN=12345 LIMIT 1";
@@ -2055,7 +2056,7 @@ public function testDelete()
public function testDeleteUsingTableAlias()
{
- $con = Propel::getServiceContainer()->getConnection(BookPeer::DATABASE_NAME);
+ $con = Propel::getServiceContainer()->getConnection(BookTableMap::DATABASE_NAME);
$c = new ModelCriteria('bookstore', 'Propel\Tests\Bookstore\Book');
$c->setModelAlias('b', false);
@@ -2093,7 +2094,7 @@ public function testDeleteAll()
public function testUpdate()
{
- $con = Propel::getServiceContainer()->getConnection(BookPeer::DATABASE_NAME);
+ $con = Propel::getServiceContainer()->getConnection(BookTableMap::DATABASE_NAME);
BookstoreDataPopulator::depopulate($con);
BookstoreDataPopulator::populate($con);
@@ -2126,7 +2127,7 @@ public function testUpdate()
public function testUpdateUsingTableAlias()
{
- $con = Propel::getServiceContainer()->getConnection(BookPeer::DATABASE_NAME);
+ $con = Propel::getServiceContainer()->getConnection(BookTableMap::DATABASE_NAME);
$c = new ModelCriteria('bookstore', 'Propel\Tests\Bookstore\Book');
$c->setModelAlias('b', false);