Commit ae7be288 authored by romanb's avatar romanb

[2.0] Work on single table inheritance with more functional tests.

parent 5a00a947
......@@ -30,6 +30,11 @@ namespace Doctrine\Common;
*/
interface NotifyPropertyChanged
{
/**
* Adds a listener that wants to be notified about property changes.
*
* @param PropertyChangedListener $listener
*/
public function addPropertyChangedListener(PropertyChangedListener $listener);
}
......@@ -1005,7 +1005,7 @@ abstract class AbstractPlatform
$queryFields = $this->getFieldDeclarationListSql($columns);
if (isset($options['primary']) && ! empty($options['primary'])) {
$queryFields .= ', PRIMARY KEY(' . implode(', ', array_values($options['primary'])) . ')';
$queryFields .= ', PRIMARY KEY(' . implode(', ', array_unique(array_values($options['primary']))) . ')';
}
if (isset($options['indexes']) && ! empty($options['indexes'])) {
......
......@@ -641,7 +641,7 @@ class MySqlPlatform extends AbstractPlatform
// attach all primary keys
if (isset($options['primary']) && ! empty($options['primary'])) {
$keyColumns = array_values($options['primary']);
$keyColumns = array_unique(array_values($options['primary']));
$keyColumns = array_map(array($this, 'quoteIdentifier'), $keyColumns);
$queryFields .= ', PRIMARY KEY(' . implode(', ', $keyColumns) . ')';
}
......
......@@ -504,7 +504,7 @@ class SqlitePlatform extends AbstractPlatform
}
if ( ! $autoinc && isset($options['primary']) && ! empty($options['primary'])) {
$keyColumns = array_values($options['primary']);
$keyColumns = array_unique(array_values($options['primary']));
$keyColumns = array_map(array($this, 'quoteIdentifier'), $keyColumns);
$queryFields.= ', PRIMARY KEY('.implode(', ', $keyColumns).')';
}
......
......@@ -131,11 +131,7 @@ abstract class AbstractQuery
}
/**
* Frees the resources used by the query object. It especially breaks a
* cyclic reference between the query object and it's parsers. This enables
* PHP's current GC to reclaim the memory.
* This method can therefore be used to reduce memory usage when creating a lot
* of query objects during a request.
* Frees the resources used by the query object.
*/
public function free()
{
......@@ -413,7 +409,7 @@ abstract class AbstractQuery
* Alias for getSingleResult(HYDRATE_SINGLE_SCALAR).
*
* @return mixed
* @throws QueryException If the query result is not unique.
* @throws QueryException If the query result is not unique.
*/
public function getSingleScalarResult()
{
......@@ -462,9 +458,8 @@ abstract class AbstractQuery
/**
* Executes the query.
*
* @param string $params Parameters to be sent to query.
* @param integer $hydrationMode Doctrine processing mode to be used during hydration process.
* One of the Query::HYDRATE_* constants.
* @param string $params Any additional query parameters.
* @param integer $hydrationMode Processing mode to be used during the hydration process.
* @return mixed
*/
public function execute($params = array(), $hydrationMode = null)
......
......@@ -21,6 +21,7 @@
namespace Doctrine\ORM\Internal\Hydration;
use Doctrine\Common\DoctrineException;
use \PDO;
/**
......
......@@ -869,7 +869,7 @@ final class ClassMetadata
*/
public function hasField($fieldName)
{
return isset($this->_columnNames[$fieldName]);
return isset($this->_reflectionProperties[$fieldName]);
}
/**
......
......@@ -53,7 +53,7 @@ class NativeQuery extends AbstractQuery
}
/**
* Gets the SQL query/queries that correspond to this DQL query.
* Gets the SQL query.
*
* @return mixed The built sql query or an array of all sql queries.
* @override
......@@ -64,7 +64,7 @@ class NativeQuery extends AbstractQuery
}
/**
* Executed the query.
* Executes the query.
*
* @param array $params
* @return Statement The Statement handle.
......
......@@ -21,6 +21,7 @@
namespace Doctrine\ORM;
use Doctrine\Common\DoctrineException;
use Doctrine\ORM\Mapping\AssociationMapping;
/**
......@@ -127,7 +128,7 @@ final class PersistentCollection extends \Doctrine\Common\Collections\Collection
$this->_ownerClass = $em->getClassMetadata($type);
if ($keyField !== null) {
if ( ! $this->_ownerClass->hasField($keyField)) {
\Doctrine\Common\DoctrineException::updateMe("Invalid field '$keyField' can't be used as key.");
throw DoctrineException::updateMe("Invalid field '$keyField' can't be used as key.");
}
$this->_keyField = $keyField;
}
......@@ -167,12 +168,12 @@ final class PersistentCollection extends \Doctrine\Common\Collections\Collection
$this->_owner = $entity;
$this->_association = $assoc;
if ($assoc->isInverseSide()) {
// for sure bidirectional
// for sure bi-directional
$this->_backRefFieldName = $assoc->getMappedByFieldName();
} else {
$targetClass = $this->_em->getClassMetadata($assoc->getTargetEntityName());
if ($targetClass->hasInverseAssociationMapping($assoc->getSourceFieldName())) {
// bidirectional
// bi-directional
$this->_backRefFieldName = $targetClass->getInverseAssociationMapping(
$assoc->getSourceFieldName())->getSourceFieldName();
}
......@@ -240,7 +241,7 @@ final class PersistentCollection extends \Doctrine\Common\Collections\Collection
*
* @param mixed $value
* @param string $key
* @return TRUE
* @return boolean Always TRUE.
* @override
*/
public function add($value)
......@@ -255,7 +256,6 @@ final class PersistentCollection extends \Doctrine\Common\Collections\Collection
->setValue($value, $this->_owner);
}
} else {
//TODO: Register collection as dirty with the UoW if necessary
$this->_changed();
}
......@@ -263,7 +263,7 @@ final class PersistentCollection extends \Doctrine\Common\Collections\Collection
}
/**
* Adds all entities of the other collection to this collection.
* Adds all elements of the other collection to this collection.
*
* @param object $otherCollection
* @todo Impl
......@@ -280,11 +280,13 @@ final class PersistentCollection extends \Doctrine\Common\Collections\Collection
/**
* INTERNAL:
* Sets a flag that indicates whether the collection is currently being hydrated.
* This has the following consequences:
*
* If the flag is set to TRUE, this has the following consequences:
*
* 1) During hydration, bidirectional associations are completed automatically
* by setting the back reference.
* 2) During hydration no change notifications are reported to the UnitOfWork.
* I.e. that means add() etc. do not cause the collection to be scheduled
* That means add() etc. do not cause the collection to be scheduled
* for an update.
*
* @param boolean $bool
......@@ -295,11 +297,8 @@ final class PersistentCollection extends \Doctrine\Common\Collections\Collection
}
/**
* INTERNAL: Takes a snapshot from this collection.
*
* Snapshots are used for diff processing, for example
* when a fetched collection has three elements, then two of those
* are being removed the diff would contain one element.
* INTERNAL:
* Tells this collection to take a snapshot of its current state.
*/
public function takeSnapshot()
{
......@@ -385,12 +384,23 @@ final class PersistentCollection extends \Doctrine\Common\Collections\Collection
//$this->_em->getUnitOfWork()->scheduleCollectionUpdate($this);
}*/
}
/**
* Gets a boolean flag indicating whether this colleciton is dirty which means
* its state needs to be synchronized with the database.
*
* @return boolean TRUE if the collection is dirty, FALSE otherwise.
*/
public function isDirty()
{
return $this->_isDirty;
}
/**
* Sets a boolean flag, indicating whether this collection is dirty.
*
* @param boolean $dirty Whether the collection should be marked dirty or not.
*/
public function setDirty($dirty)
{
$this->_isDirty = $dirty;
......
This diff is collapsed.
......@@ -87,74 +87,11 @@ class SchemaTool
continue;
}
$columns = $this->_gatherColumns($class); // table columns
$options = array(); // table options
$columns = $this->_gatherColumns($class, $options); // table columns
foreach ($class->getAssociationMappings() as $mapping) {
$foreignClass = $this->_em->getClassMetadata($mapping->getTargetEntityName());
if ($mapping->isOneToOne() && $mapping->isOwningSide()) {
$constraint = array();
$constraint['tableName'] = $class->getTableName();
$constraint['foreignTable'] = $foreignClass->getTableName();
$constraint['local'] = array();
$constraint['foreign'] = array();
foreach ($mapping->getJoinColumns() as $joinColumn) {
$column = array();
$column['name'] = $joinColumn['name'];
$column['type'] = $foreignClass->getTypeOfColumn($joinColumn['referencedColumnName']);
$columns[$joinColumn['name']] = $column;
$constraint['local'][] = $joinColumn['name'];
$constraint['foreign'][] = $joinColumn['referencedColumnName'];
}
$foreignKeyConstraints[] = $constraint;
} else if ($mapping->isOneToMany() && $mapping->isOwningSide()) {
//... create join table, one-many through join table supported later
throw DoctrineException::updateMe("Not yet implemented.");
} else if ($mapping->isManyToMany() && $mapping->isOwningSide()) {
// create join table
$joinTableColumns = array();
$joinTableOptions = array();
$joinTable = $mapping->getJoinTable();
$constraint1 = array();
$constraint1['tableName'] = $joinTable['name'];
$constraint1['foreignTable'] = $class->getTableName();
$constraint1['local'] = array();
$constraint1['foreign'] = array();
foreach ($joinTable['joinColumns'] as $joinColumn) {
$column = array();
$column['primary'] = true;
$joinTableOptions['primary'][] = $joinColumn['name'];
$column['name'] = $joinColumn['name'];
$column['type'] = $class->getTypeOfColumn($joinColumn['referencedColumnName']);
$joinTableColumns[$joinColumn['name']] = $column;
$constraint1['local'][] = $joinColumn['name'];
$constraint1['foreign'][] = $joinColumn['referencedColumnName'];
}
$foreignKeyConstraints[] = $constraint1;
$constraint2 = array();
$constraint2['tableName'] = $joinTable['name'];
$constraint2['foreignTable'] = $foreignClass->getTableName();
$constraint2['local'] = array();
$constraint2['foreign'] = array();
foreach ($joinTable['inverseJoinColumns'] as $inverseJoinColumn) {
$column = array();
$column['primary'] = true;
$joinTableOptions['primary'][] = $inverseJoinColumn['name'];
$column['name'] = $inverseJoinColumn['name'];
$column['type'] = $this->_em->getClassMetadata($mapping->getTargetEntityName())
->getTypeOfColumn($inverseJoinColumn['referencedColumnName']);
$joinTableColumns[$inverseJoinColumn['name']] = $column;
$constraint2['local'][] = $inverseJoinColumn['name'];
$constraint2['foreign'][] = $inverseJoinColumn['referencedColumnName'];
}
$foreignKeyConstraints[] = $constraint2;
$sql = array_merge($sql, $this->_platform->getCreateTableSql(
$joinTable['name'], $joinTableColumns, $joinTableOptions));
}
}
$this->_gatherRelationsSql($class, $sql, $columns, $foreignKeyConstraints);
if ($class->isInheritanceTypeSingleTable()) {
// Add the discriminator column
$discrColumnDef = $this->_getDiscriminatorColumnDefinition($class);
......@@ -166,7 +103,9 @@ class SchemaTool
$processedClasses[$parentClassName] = true;
}
foreach ($class->getSubclasses() as $subClassName) {
$columns = array_merge($columns, $this->_gatherColumns($this->_em->getClassMetadata($subClassName)));
$subClass = $this->_em->getClassMetadata($subClassName);
$columns = array_merge($columns, $this->_gatherColumns($subClass, $options));
$this->_gatherRelationsSql($subClass, $sql, $columns, $foreignKeyConstraints);
$processedClasses[$subClassName] = true;
}
} else if ($class->isInheritanceTypeJoined()) {
......@@ -200,7 +139,7 @@ class SchemaTool
);
}
private function _gatherColumns($class)
private function _gatherColumns($class, array &$options)
{
$columns = array();
foreach ($class->getFieldMappings() as $fieldName => $mapping) {
......@@ -218,9 +157,78 @@ class SchemaTool
}
$columns[$mapping['columnName']] = $column;
}
return $columns;
}
private function _gatherRelationsSql($class, array &$sql, array &$columns, array &$constraints)
{
foreach ($class->getAssociationMappings() as $mapping) {
$foreignClass = $this->_em->getClassMetadata($mapping->getTargetEntityName());
if ($mapping->isOneToOne() && $mapping->isOwningSide()) {
$constraint = array();
$constraint['tableName'] = $class->getTableName();
$constraint['foreignTable'] = $foreignClass->getTableName();
$constraint['local'] = array();
$constraint['foreign'] = array();
foreach ($mapping->getJoinColumns() as $joinColumn) {
$column = array();
$column['name'] = $joinColumn['name'];
$column['type'] = $foreignClass->getTypeOfColumn($joinColumn['referencedColumnName']);
$columns[$joinColumn['name']] = $column;
$constraint['local'][] = $joinColumn['name'];
$constraint['foreign'][] = $joinColumn['referencedColumnName'];
}
$constraints[] = $constraint;
} else if ($mapping->isOneToMany() && $mapping->isOwningSide()) {
//... create join table, one-many through join table supported later
throw DoctrineException::updateMe("Not yet implemented.");
} else if ($mapping->isManyToMany() && $mapping->isOwningSide()) {
// create join table
$joinTableColumns = array();
$joinTableOptions = array();
$joinTable = $mapping->getJoinTable();
$constraint1 = array();
$constraint1['tableName'] = $joinTable['name'];
$constraint1['foreignTable'] = $class->getTableName();
$constraint1['local'] = array();
$constraint1['foreign'] = array();
foreach ($joinTable['joinColumns'] as $joinColumn) {
$column = array();
$column['primary'] = true;
$joinTableOptions['primary'][] = $joinColumn['name'];
$column['name'] = $joinColumn['name'];
$column['type'] = $class->getTypeOfColumn($joinColumn['referencedColumnName']);
$joinTableColumns[$joinColumn['name']] = $column;
$constraint1['local'][] = $joinColumn['name'];
$constraint1['foreign'][] = $joinColumn['referencedColumnName'];
}
$constraints[] = $constraint1;
$constraint2 = array();
$constraint2['tableName'] = $joinTable['name'];
$constraint2['foreignTable'] = $foreignClass->getTableName();
$constraint2['local'] = array();
$constraint2['foreign'] = array();
foreach ($joinTable['inverseJoinColumns'] as $inverseJoinColumn) {
$column = array();
$column['primary'] = true;
$joinTableOptions['primary'][] = $inverseJoinColumn['name'];
$column['name'] = $inverseJoinColumn['name'];
$column['type'] = $this->_em->getClassMetadata($mapping->getTargetEntityName())
->getTypeOfColumn($inverseJoinColumn['referencedColumnName']);
$joinTableColumns[$inverseJoinColumn['name']] = $column;
$constraint2['local'][] = $inverseJoinColumn['name'];
$constraint2['foreign'][] = $inverseJoinColumn['referencedColumnName'];
}
$constraints[] = $constraint2;
$sql = array_merge($sql, $this->_platform->getCreateTableSql(
$joinTable['name'], $joinTableColumns, $joinTableOptions));
}
}
}
public function dropSchema(array $classes)
{
//TODO
......
......@@ -333,10 +333,6 @@ class UnitOfWork implements PropertyChangedListener
$oid = spl_object_hash($entity);
$state = $this->getEntityState($entity);
if ($state == self::STATE_MANAGED && ($entity instanceof \Doctrine\Common\NotifyPropertyChanged)) {
continue; // entity notifies us, no need to calculate changes
}
// Look for changes in the entity itself by comparing against the
// original data we have.
if ($state == self::STATE_MANAGED || $state == self::STATE_NEW) {
......
......@@ -15,21 +15,28 @@ class SingleTableInheritanceTest extends \Doctrine\Tests\OrmFunctionalTestCase
parent::setUp();
$this->_schemaTool->createSchema(array(
$this->_em->getClassMetadata('Doctrine\Tests\ORM\Functional\ParentEntity'),
$this->_em->getClassMetadata('Doctrine\Tests\ORM\Functional\ChildEntity')
$this->_em->getClassMetadata('Doctrine\Tests\ORM\Functional\ChildEntity'),
$this->_em->getClassMetadata('Doctrine\Tests\ORM\Functional\RelatedEntity')
));
}
public function testInsert()
public function testCRUD()
{
$parent = new ParentEntity;
$parent->setData('foobar');
$this->_em->save($parent);
$relatedEntity = new RelatedEntity;
$relatedEntity->setName('theRelatedOne');
$this->_em->save($relatedEntity);
$child = new ChildEntity;
$child->setData('thedata');
$child->setNumber(1234);
$child->setRelatedEntity($relatedEntity);
$this->_em->save($child);
......@@ -43,9 +50,45 @@ class SingleTableInheritanceTest extends \Doctrine\Tests\OrmFunctionalTestCase
$this->assertEquals(2, count($entities));
$this->assertTrue($entities[0] instanceof ParentEntity);
$this->assertTrue($entities[1] instanceof ChildEntity);
$this->assertTrue(is_numeric($entities[0]->getId()));
$this->assertTrue(is_numeric($entities[1]->getId()));
$this->assertEquals('foobar', $entities[0]->getData());
$this->assertEquals('thedata', $entities[1]->getData());
$this->assertEquals(1234, $entities[1]->getNumber());
$this->_em->clear();
$query = $this->_em->createQuery("select e from Doctrine\Tests\ORM\Functional\ChildEntity e");
$entities = $query->getResultList();
$this->assertEquals(1, count($entities));
$this->assertTrue($entities[0] instanceof ChildEntity);
$this->assertTrue(is_numeric($entities[0]->getId()));
$this->assertEquals('thedata', $entities[0]->getData());
$this->assertEquals(1234, $entities[0]->getNumber());
$this->_em->clear();
$query = $this->_em->createQuery("select r,o from Doctrine\Tests\ORM\Functional\RelatedEntity r join r.owner o");
$entities = $query->getResultList();
$this->assertEquals(1, count($entities));
$this->assertTrue($entities[0] instanceof RelatedEntity);
$this->assertTrue(is_numeric($entities[0]->getId()));
$this->assertEquals('theRelatedOne', $entities[0]->getName());
$this->assertTrue($entities[0]->getOwner() instanceof ChildEntity);
$this->assertEquals('thedata', $entities[0]->getOwner()->getData());
$this->assertSame($entities[0], $entities[0]->getOwner()->getRelatedEntity());
$query = $this->_em->createQuery("update Doctrine\Tests\ORM\Functional\ChildEntity e set e.data = 'newdata'");
$affected = $query->execute();
$this->assertEquals(1, $affected);
$query = $this->_em->createQuery("delete Doctrine\Tests\ORM\Functional\ParentEntity e");
$affected = $query->execute();
$this->assertEquals(2, $affected);
}
}
......@@ -91,6 +134,11 @@ class ChildEntity extends ParentEntity {
* @DoctrineColumn(type="integer", nullable=true)
*/
private $number;
/**
* @DoctrineOneToOne(targetEntity="RelatedEntity")
* @DoctrineJoinColumn(name="related_entity_id", referencedColumnName="id")
*/
private $relatedEntity;
public function getNumber() {
return $this->number;
......@@ -99,5 +147,56 @@ class ChildEntity extends ParentEntity {
public function setNumber($number) {
$this->number = $number;
}
public function getRelatedEntity() {
return $this->relatedEntity;
}
public function setRelatedEntity($relatedEntity) {
$this->relatedEntity = $relatedEntity;
$relatedEntity->setOwner($this);
}
}
/**
* @DoctrineEntity
*/
class RelatedEntity {
/**
* @DoctrineId
* @DoctrineColumn(type="integer")
* @DoctrineGeneratedValue(strategy="auto")
*/
private $id;
/**
* @DoctrineColumn(type="varchar", length=50)
*/
private $name;
/**
* @DoctrineOneToOne(targetEntity="ChildEntity", mappedBy="relatedEntity")
*/
private $owner;
public function getId() {
return $this->id;
}
public function getName() {
return $this->name;
}
public function setName($name) {
$this->name = $name;
}
public function getOwner() {
return $this->owner;
}
public function setOwner($owner) {
$this->owner = $owner;
if ($owner->getRelatedEntity() !== $this) {
$owner->setRelatedEntity($this);
}
}
}
......@@ -60,11 +60,11 @@ class DeleteSqlGenerationTest extends \Doctrine\Tests\OrmTestCase
{
$this->assertSqlGeneration(
'DELETE Doctrine\Tests\Models\CMS\CmsUser u',
'DELETE FROM cms_users c0_'
'DELETE FROM cms_users'
);
$this->assertSqlGeneration(
'DELETE FROM Doctrine\Tests\Models\CMS\CmsUser u',
'DELETE FROM cms_users c0_'
'DELETE FROM cms_users'
);
}
......@@ -72,7 +72,7 @@ class DeleteSqlGenerationTest extends \Doctrine\Tests\OrmTestCase
{
$this->assertSqlGeneration(
'DELETE Doctrine\Tests\Models\CMS\CmsUser u WHERE u.id = ?1',
'DELETE FROM cms_users c0_ WHERE c0_.id = ?'
'DELETE FROM cms_users WHERE id = ?'
);
}
......@@ -80,12 +80,12 @@ class DeleteSqlGenerationTest extends \Doctrine\Tests\OrmTestCase
{
$this->assertSqlGeneration(
'DELETE Doctrine\Tests\Models\CMS\CmsUser u WHERE u.username = ?1 OR u.name = ?2',
'DELETE FROM cms_users c0_ WHERE c0_.username = ? OR c0_.name = ?'
'DELETE FROM cms_users WHERE username = ? OR name = ?'
);
$this->assertSqlGeneration(
'DELETE Doctrine\Tests\Models\CMS\CmsUser u WHERE u.id = ?1 OR ( u.username = ?2 OR u.name = ?3)',
'DELETE FROM cms_users c0_ WHERE c0_.id = ? OR (c0_.username = ? OR c0_.name = ?)'
'DELETE FROM cms_users WHERE id = ? OR (username = ? OR name = ?)'
);
//$this->assertSqlGeneration(
......@@ -98,7 +98,7 @@ class DeleteSqlGenerationTest extends \Doctrine\Tests\OrmTestCase
{
$this->assertSqlGeneration(
"delete from Doctrine\Tests\Models\CMS\CmsUser u where u.username = ?1",
"DELETE FROM cms_users c0_ WHERE c0_.username = ?"
"DELETE FROM cms_users WHERE username = ?"
);
}
......@@ -106,7 +106,7 @@ class DeleteSqlGenerationTest extends \Doctrine\Tests\OrmTestCase
{
$this->assertSqlGeneration(
"DELETE Doctrine\Tests\Models\CMS\CmsUser u WHERE u.username = ?1 AND u.name = ?2",
"DELETE FROM cms_users c0_ WHERE c0_.username = ? AND c0_.name = ?"
"DELETE FROM cms_users WHERE username = ? AND name = ?"
);
}
......@@ -114,17 +114,17 @@ class DeleteSqlGenerationTest extends \Doctrine\Tests\OrmTestCase
{
$this->assertSqlGeneration(
"DELETE Doctrine\Tests\Models\CMS\CmsUser u WHERE NOT u.id != ?1",
"DELETE FROM cms_users c0_ WHERE NOT c0_.id <> ?"
"DELETE FROM cms_users WHERE NOT id <> ?"
);
$this->assertSqlGeneration(
"DELETE Doctrine\Tests\Models\CMS\CmsUser u WHERE NOT ( u.id != ?1 )",
"DELETE FROM cms_users c0_ WHERE NOT (c0_.id <> ?)"
"DELETE FROM cms_users WHERE NOT (id <> ?)"
);
$this->assertSqlGeneration(
"DELETE Doctrine\Tests\Models\CMS\CmsUser u WHERE NOT ( u.id != ?1 AND u.username = ?2 )",
"DELETE FROM cms_users c0_ WHERE NOT (c0_.id <> ? AND c0_.username = ?)"
"DELETE FROM cms_users WHERE NOT (id <> ? AND username = ?)"
);
}
......@@ -135,32 +135,32 @@ class DeleteSqlGenerationTest extends \Doctrine\Tests\OrmTestCase
// id = ? was already tested (see testDeleteWithWhere())
$this->assertSqlGeneration(
"DELETE Doctrine\Tests\Models\CMS\CmsUser u WHERE u.id > ?1",
"DELETE FROM cms_users c0_ WHERE c0_.id > ?"
"DELETE FROM cms_users WHERE id > ?"
);
$this->assertSqlGeneration(
"DELETE Doctrine\Tests\Models\CMS\CmsUser u WHERE u.id >= ?1",
"DELETE FROM cms_users c0_ WHERE c0_.id >= ?"
"DELETE FROM cms_users WHERE id >= ?"
);
$this->assertSqlGeneration(
"DELETE Doctrine\Tests\Models\CMS\CmsUser u WHERE u.id < ?1",
"DELETE FROM cms_users c0_ WHERE c0_.id < ?"
"DELETE FROM cms_users WHERE id < ?"
);
$this->assertSqlGeneration(
"DELETE Doctrine\Tests\Models\CMS\CmsUser u WHERE u.id <= ?1",
"DELETE FROM cms_users c0_ WHERE c0_.id <= ?"
"DELETE FROM cms_users WHERE id <= ?"
);
$this->assertSqlGeneration(
"DELETE Doctrine\Tests\Models\CMS\CmsUser u WHERE u.id <> ?1",
"DELETE FROM cms_users c0_ WHERE c0_.id <> ?"
"DELETE FROM cms_users WHERE id <> ?"
);
$this->assertSqlGeneration(
"DELETE Doctrine\Tests\Models\CMS\CmsUser u WHERE u.id != ?1",
"DELETE FROM cms_users c0_ WHERE c0_.id <> ?"
"DELETE FROM cms_users WHERE id <> ?"
);
}
......@@ -168,12 +168,12 @@ class DeleteSqlGenerationTest extends \Doctrine\Tests\OrmTestCase
{
$this->assertSqlGeneration(
"DELETE Doctrine\Tests\Models\CMS\CmsUser u WHERE u.id NOT BETWEEN ?1 AND ?2",
"DELETE FROM cms_users c0_ WHERE c0_.id NOT BETWEEN ? AND ?"
"DELETE FROM cms_users WHERE id NOT BETWEEN ? AND ?"
);
$this->assertSqlGeneration(
"DELETE Doctrine\Tests\Models\CMS\CmsUser u WHERE u.id BETWEEN ?1 AND ?2 AND u.username != ?3",
"DELETE FROM cms_users c0_ WHERE c0_.id BETWEEN ? AND ? AND c0_.username <> ?"
"DELETE FROM cms_users WHERE id BETWEEN ? AND ? AND username <> ?"
);
}
......@@ -182,12 +182,12 @@ class DeleteSqlGenerationTest extends \Doctrine\Tests\OrmTestCase
// "WHERE" Expression LikeExpression
$this->assertSqlGeneration(
'DELETE Doctrine\Tests\Models\CMS\CmsUser u WHERE u.username NOT LIKE ?1',
'DELETE FROM cms_users c0_ WHERE c0_.username NOT LIKE ?'
'DELETE FROM cms_users WHERE username NOT LIKE ?'
);
$this->assertSqlGeneration(
"DELETE Doctrine\Tests\Models\CMS\CmsUser u WHERE u.username LIKE ?1 ESCAPE '\\'",
"DELETE FROM cms_users c0_ WHERE c0_.username LIKE ? ESCAPE '\\'"
"DELETE FROM cms_users WHERE username LIKE ? ESCAPE '\\'"
);
}
......@@ -196,12 +196,12 @@ class DeleteSqlGenerationTest extends \Doctrine\Tests\OrmTestCase
// "WHERE" Expression NullComparisonExpression
$this->assertSqlGeneration(
'DELETE Doctrine\Tests\Models\CMS\CmsUser u WHERE u.name IS NULL',
'DELETE FROM cms_users c0_ WHERE c0_.name IS NULL'
'DELETE FROM cms_users WHERE name IS NULL'
);
$this->assertSqlGeneration(
'DELETE Doctrine\Tests\Models\CMS\CmsUser u WHERE u.name IS NOT NULL',
'DELETE FROM cms_users c0_ WHERE c0_.name IS NOT NULL'
'DELETE FROM cms_users WHERE name IS NOT NULL'
);
}
......@@ -209,12 +209,12 @@ class DeleteSqlGenerationTest extends \Doctrine\Tests\OrmTestCase
{
$this->assertSqlGeneration(
'DELETE Doctrine\Tests\Models\CMS\CmsUser u WHERE 1 = 1',
'DELETE FROM cms_users c0_ WHERE 1 = 1'
'DELETE FROM cms_users WHERE 1 = 1'
);
$this->assertSqlGeneration(
'DELETE Doctrine\Tests\Models\CMS\CmsUser u WHERE ?1 = 1',
'DELETE FROM cms_users c0_ WHERE ? = 1'
'DELETE FROM cms_users WHERE ? = 1'
);
}
......@@ -222,12 +222,12 @@ class DeleteSqlGenerationTest extends \Doctrine\Tests\OrmTestCase
{
$this->assertSqlGeneration(
'DELETE Doctrine\Tests\Models\CMS\CmsUser u WHERE u.id IN ( ?1, ?2, ?3, ?4 )',
'DELETE FROM cms_users c0_ WHERE c0_.id IN (?, ?, ?, ?)'
'DELETE FROM cms_users WHERE id IN (?, ?, ?, ?)'
);
$this->assertSqlGeneration(
'DELETE Doctrine\Tests\Models\CMS\CmsUser u WHERE u.id NOT IN ( ?1, ?2 )',
'DELETE FROM cms_users c0_ WHERE c0_.id NOT IN (?, ?)'
'DELETE FROM cms_users WHERE id NOT IN (?, ?)'
);
}
......
......@@ -60,11 +60,11 @@ class UpdateSqlGenerationTest extends \Doctrine\Tests\OrmTestCase
{
$this->assertSqlGeneration(
'UPDATE Doctrine\Tests\Models\CMS\CmsUser u SET u.name = ?1',
'UPDATE cms_users c0_ SET c0_.name = ?'
'UPDATE cms_users SET name = ?'
);
$this->assertSqlGeneration(
'UPDATE Doctrine\Tests\Models\CMS\CmsUser u SET u.name = ?1, u.username = ?2',
'UPDATE cms_users c0_ SET c0_.name = ?, c0_.username = ?'
'UPDATE cms_users SET name = ?, username = ?'
);
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment