1
0
mirror of synced 2025-01-18 06:21:40 +03:00

Merge branch 'master' of github.com:doctrine/doctrine2

This commit is contained in:
Guilherme Blanco 2012-07-25 01:24:33 -04:00
commit 1eaa822d2a
8 changed files with 226 additions and 23 deletions

View File

@ -429,7 +429,7 @@ class QueryBuilder
* *
* @param mixed $key The key (index or name) of the bound parameter. * @param mixed $key The key (index or name) of the bound parameter.
* *
* @return mixed The value of the bound parameter. * @return Query\Parameter|null The value of the bound parameter.
*/ */
public function getParameter($key) public function getParameter($key)
{ {
@ -1169,5 +1169,13 @@ class QueryBuilder
$this->_dqlParts[$part] = clone $elements; $this->_dqlParts[$part] = clone $elements;
} }
} }
$parameters = array();
foreach ($this->parameters as $parameter) {
$parameters[] = clone $parameter;
}
$this->parameters = new ArrayCollection($parameters);
} }
} }

View File

@ -52,20 +52,19 @@ class MetadataCommand extends Console\Command\Command
) )
)); ));
$fullName = $this->getName();
$this->setHelp(<<<EOT $this->setHelp(<<<EOT
The <info>$fullName</info> command is meant to clear the metadata cache of associated Entity Manager. The <info>%command.name%</info> command is meant to clear the metadata cache of associated Entity Manager.
It is possible to invalidate all cache entries at once - called delete -, or flushes the cache provider It is possible to invalidate all cache entries at once - called delete -, or flushes the cache provider
instance completely. instance completely.
The execution type differ on how you execute the command. The execution type differ on how you execute the command.
If you want to invalidate the entries (and not delete from cache instance), this command would do the work: If you want to invalidate the entries (and not delete from cache instance), this command would do the work:
<info>$fullName</info> <info>%command.name%</info>
Alternatively, if you want to flush the cache provider using this command: Alternatively, if you want to flush the cache provider using this command:
<info>$fullName --flush</info> <info>%command.name% --flush</info>
Finally, be aware that if <info>--flush</info> option is passed, not all cache providers are able to flush entries, Finally, be aware that if <info>--flush</info> option is passed, not all cache providers are able to flush entries,
because of a limitation of its execution nature. because of a limitation of its execution nature.

View File

@ -52,20 +52,19 @@ class QueryCommand extends Console\Command\Command
) )
)); ));
$fullName = $this->getName();
$this->setHelp(<<<EOT $this->setHelp(<<<EOT
The <info>$fullName</info> command is meant to clear the query cache of associated Entity Manager. The <info>%command.name%</info> command is meant to clear the query cache of associated Entity Manager.
It is possible to invalidate all cache entries at once - called delete -, or flushes the cache provider It is possible to invalidate all cache entries at once - called delete -, or flushes the cache provider
instance completely. instance completely.
The execution type differ on how you execute the command. The execution type differ on how you execute the command.
If you want to invalidate the entries (and not delete from cache instance), this command would do the work: If you want to invalidate the entries (and not delete from cache instance), this command would do the work:
<info>$fullName</info> <info>%command.name%</info>
Alternatively, if you want to flush the cache provider using this command: Alternatively, if you want to flush the cache provider using this command:
<info>$fullName --flush</info> <info>%command.name% --flush</info>
Finally, be aware that if <info>--flush</info> option is passed, not all cache providers are able to flush entries, Finally, be aware that if <info>--flush</info> option is passed, not all cache providers are able to flush entries,
because of a limitation of its execution nature. because of a limitation of its execution nature.

View File

@ -52,20 +52,19 @@ class ResultCommand extends Console\Command\Command
) )
)); ));
$fullName = $this->getName();
$this->setHelp(<<<EOT $this->setHelp(<<<EOT
The <info>$fullName</info> command is meant to clear the result cache of associated Entity Manager. The <info>%command.name%</info> command is meant to clear the result cache of associated Entity Manager.
It is possible to invalidate all cache entries at once - called delete -, or flushes the cache provider It is possible to invalidate all cache entries at once - called delete -, or flushes the cache provider
instance completely. instance completely.
The execution type differ on how you execute the command. The execution type differ on how you execute the command.
If you want to invalidate the entries (and not delete from cache instance), this command would do the work: If you want to invalidate the entries (and not delete from cache instance), this command would do the work:
<info>$fullName</info> <info>%command.name%</info>
Alternatively, if you want to flush the cache provider using this command: Alternatively, if you want to flush the cache provider using this command:
<info>$fullName --flush</info> <info>%command.name% --flush</info>
Finally, be aware that if <info>--flush</info> option is passed, not all cache providers are able to flush entries, Finally, be aware that if <info>--flush</info> option is passed, not all cache providers are able to flush entries,
because of a limitation of its execution nature. because of a limitation of its execution nature.

View File

@ -40,7 +40,7 @@ class InfoCommand extends Command
->setName('orm:info') ->setName('orm:info')
->setDescription('Show basic information about all mapped entities') ->setDescription('Show basic information about all mapped entities')
->setHelp(<<<EOT ->setHelp(<<<EOT
The <info>doctrine:mapping:info</info> shows basic information about which The <info>%command.name%</info> shows basic information about which
entities exist and possibly if their mapping information contains errors or entities exist and possibly if their mapping information contains errors or
not. not.
EOT EOT

View File

@ -68,20 +68,19 @@ class UpdateCommand extends AbstractCommand
), ),
)); ));
$fullName = $this->getName();
$this->setHelp(<<<EOT $this->setHelp(<<<EOT
The <info>$fullName</info> command generates the SQL needed to The <info>%command.name%</info> command generates the SQL needed to
synchronize the database schema with the current mapping metadata of the synchronize the database schema with the current mapping metadata of the
default entity manager. default entity manager.
For example, if you add metadata for a new column to an entity, this command For example, if you add metadata for a new column to an entity, this command
would generate and output the SQL needed to add the new column to the database: would generate and output the SQL needed to add the new column to the database:
<info>$fullName --dump-sql</info> <info>%command.name% --dump-sql</info>
Alternatively, you can execute the generated queries: Alternatively, you can execute the generated queries:
<info>$fullName --force</info> <info>%command.name% --force</info>
Finally, be aware that if the <info>--complete</info> option is passed, this Finally, be aware that if the <info>--complete</info> option is passed, this
task will drop all database assets (e.g. tables, etc) that are *not* described task will drop all database assets (e.g. tables, etc) that are *not* described

View File

@ -0,0 +1,182 @@
<?php
namespace Doctrine\Tests\ORM\Functional\Ticket;
use Doctrine\Common\Collections\ArrayCollection;
require_once __DIR__ . '/../../../TestInit.php';
/**
* @group DDC-1925
* @group DDC-1210
*/
class DDC1925Test extends \Doctrine\Tests\OrmFunctionalTestCase
{
public function testIssue()
{
$this->_schemaTool->createSchema(array(
$this->_em->getClassMetadata(__NAMESPACE__ . '\\DDC1925User'),
$this->_em->getClassMetadata(__NAMESPACE__ . '\\DDC1925Product'),
));
$user = new DDC1925User();
$user->setTitle("Test User");
$this->_em->persist($user);
$product = new DDC1925Product();
$product->setTitle("Test product");
$this->_em->persist($product);
$this->_em->flush();
$product->addBuyer($user);
$this->_em->getUnitOfWork()->computeChangeSets();
$this->_em->persist($product);
$this->_em->flush();
}
}
/**
* @Table
* @Entity
*/
class DDC1925Product
{
/**
* @var integer $id
*
* @Column(name="id", type="integer")
* @Id
* @GeneratedValue(strategy="AUTO")
*/
private $id;
/**
* @var string $title
*
* @Column(name="title", type="string", length=255)
*/
private $title;
/**
* @ManyToMany(targetEntity="DDC1925User")
* @JoinTable(
* name="user_purchases",
* joinColumns={@JoinColumn(name="product_id", referencedColumnName="id")},
* inverseJoinColumns={@JoinColumn(name="user_id", referencedColumnName="id")}
* )
*/
private $buyers;
/**
* Default constructor
*/
public function __construct()
{
$this->buyers = new ArrayCollection();
}
/**
* @return integer
*/
public function getId()
{
return $this->id;
}
/**
* @param string $title
*/
public function setTitle($title)
{
$this->title = $title;
}
/**
* Get title
*
* @return string
*/
public function getTitle()
{
return $this->title;
}
/**
* @param string $buyers
*/
public function setBuyers($buyers)
{
$this->buyers = $buyers;
}
/**
* @return string
*/
public function getBuyers()
{
return $this->buyers;
}
/**
* @param DDC1925User $buyer
*/
public function addBuyer(DDC1925User $buyer)
{
$this->buyers[] = $buyer;
}
}
/**
* @Table
* @Entity
*/
class DDC1925User
{
/**
* @var integer
*
* @Column(name="id", type="integer")
* @Id
* @GeneratedValue(strategy="AUTO")
*/
private $id;
/**
* @var string
*
* @Column(name="title", type="string", length=255)
*/
private $title;
/**
* Get id
*
* @return integer
*/
public function getId()
{
return $this->id;
}
/**
* Set title
*
* @param string $title
*/
public function setTitle($title)
{
$this->title = $title;
}
/**
* Get title
*
* @return string
*/
public function getTitle()
{
return $this->title;
}
}

View File

@ -664,6 +664,23 @@ class QueryBuilderTest extends \Doctrine\Tests\OrmTestCase
$this->assertEquals(2, $expr->count(), "Modifying the second query should affect the first one."); $this->assertEquals(2, $expr->count(), "Modifying the second query should affect the first one.");
} }
/**
* @group DDC-1933
*/
public function testParametersAreCloned()
{
$originalQb = new QueryBuilder($this->_em);
$originalQb->setParameter('parameter1', 'value1');
$copy = clone $originalQb;
$copy->setParameter('parameter2', 'value2');
$this->assertCount(1, $originalQb->getParameters());
$this->assertSame('value1', $copy->getParameter('parameter1')->getValue());
$this->assertSame('value2', $copy->getParameter('parameter2')->getValue());
}
public function testGetRootAlias() public function testGetRootAlias()
{ {
$qb = $this->_em->createQueryBuilder() $qb = $this->_em->createQueryBuilder()