Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[DDC 2004] addFilter class name or instance #557

Closed
wants to merge 170 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
170 commits
Select commit Hold shift + click to select a range
3e53d9d
Changed commands to use command.name in the help
stof Jul 16, 2012
5b55739
Moved implementation from EntityRepository to EntityManager. This dec…
guilhermeblanco Jul 23, 2012
2389f77
Fixed DefaultRepositoryClassName which should follow the Persistence …
guilhermeblanco Jul 25, 2012
2158a07
[2.3] Use HelperSet in cli-config.php
igorw Jul 26, 2012
ac9df05
Fixed is_subclass_of comparing an interface which brought our require…
guilhermeblanco Jul 26, 2012
369a30a
Added the new DBAL 2.3 types in the EntityGenerator typehint map
stof Jul 27, 2012
bd1e6ac
Merge pull request #410 from igorw/helper-set
beberlei Jul 29, 2012
13d32e6
Merge remote-tracking branch 'origin/2.3' into 2.3
beberlei Jul 29, 2012
ef27721
Merge remote-tracking branch 'origin/2.3' into 2.3
beberlei Jul 29, 2012
dfa6ff6
DDC-1939 - Removing references to non-existing AssociationMapping class
Ocramius Jul 24, 2012
e2c40dc
[DDC-1939] Add test for persistent collection delete with composite key
beberlei Jul 29, 2012
d7bdae3
Merge branch 'DDC-1939' into 2.3
beberlei Jul 29, 2012
e63575e
added failing test for refresh with eager fetching
schmittjoh Jul 26, 2012
7f68347
[DDC-1964] Fix issue with refresh and and object hydrator not setting…
beberlei Jul 29, 2012
7029d37
Merge branch 'DDC-1964' into 2.3
beberlei Jul 29, 2012
1e2eca1
DDC-1933 - Fixing cloning of QueryBuilder and adding related tests
Ocramius Jul 19, 2012
6dd3078
[DDC-1937] Fix bug with apc and annotation caching using a workaround.
beberlei Jul 29, 2012
1676cf2
Merge branch 'DDC-1937' into 2.3
beberlei Jul 29, 2012
c55394c
Bump dependencies
beberlei Jul 29, 2012
5527e12
Release 2.3.0-RC1
beberlei Jul 29, 2012
992b51e
Bump dev version to 2.3.0
beberlei Jul 29, 2012
3b3d762
[DDC-1961] Fixed parameter type support in Parameter
Majkl578 Jul 31, 2012
3f2ddc6
Merge pull request #416 from Majkl578/DDC-1961
guilhermeblanco Jul 31, 2012
c99c7b6
Update EntityRepository and PersistentCollection to new Criteria#expr…
beberlei Aug 1, 2012
17862d9
Merge branch 'CriteriaExpressionBuilder' into 2.3
beberlei Aug 1, 2012
2e6b50b
Create the setCustomHydrationMode function
Aug 14, 2012
af08f05
Fix setCustomHydrationModes + added test
asm89 Aug 14, 2012
971865f
Merge branch 'config' into 2.3
asm89 Aug 14, 2012
3aaa90e
Fix ORMInvalidArgumentException factory methods with return instead o…
chEbba Aug 19, 2012
9d909cd
Fix DDC-1977
FabioBatSilva Aug 15, 2012
48e9434
Merge pull request #427 from chEbba/return-exception
beberlei Aug 29, 2012
131d300
Merge remote-tracking branch 'origin/master' into 2.3
beberlei Aug 29, 2012
f4ba583
[DDC-1918] Fix weird results at the end of paginator when using fetch…
beberlei Aug 29, 2012
8c1d643
Merge remote-tracking branch 'origin/2.3' into 2.3
beberlei Aug 29, 2012
bdb36a7
Merge branch 'DDC-1918' into 2.3
beberlei Aug 29, 2012
114e233
Revert "Merge remote-tracking branch 'origin/master' into 2.3"
beberlei Aug 29, 2012
d181fbc
Release 2.3.0-RC2
beberlei Aug 29, 2012
1a81444
Bump dev version to 2.3.0
beberlei Aug 29, 2012
9308afc
Release 2.3.0-RC2
beberlei Aug 29, 2012
bbf527a
Bump dev version to 2.3.0
beberlei Aug 29, 2012
2597192
Added a failing test for DDC-2003
Josiah Aug 31, 2012
366c6a7
Fixed DDC-2003 using closures to reference the functionality of the c…
Josiah Aug 31, 2012
0dcfabb
Removed the closure keyword as it isn't supported in PHP 5.3
Josiah Aug 31, 2012
c76280b
Fixed formatting issues identified by Stof
Josiah Aug 31, 2012
9cdee12
Refactored the SqlValueVisitor to move all type processing to the ent…
Josiah Aug 31, 2012
30ad1b0
[DDC-2003] Remove unused variable
beberlei Sep 5, 2012
741080d
Merge branch 'DDC-2003' into 2.3
beberlei Sep 5, 2012
8edecfd
Bump DBAL dependency
beberlei Sep 5, 2012
a96bbbb
Release 2.3.0-RC3
beberlei Sep 5, 2012
4d9f24b
Bump dev version to 2.3.0
beberlei Sep 5, 2012
53e164b
Update lib/Doctrine/ORM/Tools/Export/Driver/XmlExporter.php
Sep 13, 2012
387516f
Merge branch 'DDC-2027' into 2.3
beberlei Sep 17, 2012
0da0d02
remove duplicate code
FabioBatSilva Sep 13, 2012
3fd8392
Merge branch 'DDC-2026' into 2.3
beberlei Sep 17, 2012
85e5398
Several fixes for comments
Powerhamster Sep 6, 2012
d7da012
added missing use statement
Powerhamster Sep 6, 2012
c2b82fa
Merge branch 'DDC-2014' into 2.3
beberlei Sep 17, 2012
44a56e8
Added a failing test case on PersistentCollection::matching() when co…
Sep 7, 2012
18a7fc5
Fixes PersistentCollection::matching() when collection is not initial…
Sep 7, 2012
586aea0
use of assertCount
Sep 7, 2012
2353736
Merge branch 'DDC-2015' into 2.3
beberlei Sep 17, 2012
3294900
Update dependencies
beberlei Sep 17, 2012
75e968b
Adjust MysqlSchemaToolTest to DBAL changes
beberlei Sep 17, 2012
477642a
Release 2.3.0-RC4
beberlei Sep 17, 2012
c610131
Bump dev version to 2.3.0
beberlei Sep 17, 2012
585c9fd
Bump versions
beberlei Sep 20, 2012
b5e19dc
Release 2.3.0
beberlei Sep 20, 2012
ea2b288
Bump dev version to 2.3.1
beberlei Sep 20, 2012
084101e
Fix DDC-2012
FabioBatSilva Sep 30, 2012
04262e2
Merge branch 'DDC-2012' into 2.3
beberlei Oct 3, 2012
c60e652
Fix test case
FabioBatSilva Sep 30, 2012
4109f22
[DDC-2059] Fix column and foreign key interfering with each other dur…
beberlei Oct 5, 2012
518357d
Merge branch 'DDC-2059' into 2.3
beberlei Oct 5, 2012
abd1137
Fixed unique-constraint name in XML Exporter
Sep 26, 2012
825a68b
Merge branch 'DDC-2044' into 2.3
beberlei Oct 5, 2012
8b2c92a
typo fix
goetas Sep 13, 2012
cb0cdde
spaces
goetas Sep 13, 2012
564ec1e
Merge branch 'DDC-2028' into 2.3
beberlei Oct 5, 2012
1988944
fix typo
jakoch Oct 12, 2012
2e5d741
Fixed bug with comment option not being added to column.
Oct 11, 2012
e8412b8
Merge branch 'DDC-2068' into 2.3
beberlei Oct 12, 2012
26cfbdd
[DDC-2067] Refactor and fix bug in boolean evaluation inside XML Driver.
beberlei Oct 12, 2012
6bad010
Merge branch 'DDC-2067' into 2.3
beberlei Oct 12, 2012
b53c81a
Fix and test for DDC-2073
mnapoli Nov 6, 2012
ef4ff8b
Fix and test for DDC-2073
mnapoli Nov 6, 2012
737e47e
Merge branch 'DDC-2073' into 2.3
beberlei Nov 9, 2012
d64be28
Fix DDC-2121
FabioBatSilva Nov 5, 2012
994917a
Merge branch 'DDC-2121' into 2.3
beberlei Nov 9, 2012
b610855
Fixed errors:
Nov 5, 2012
9b198be
Merge branch 'DDC-2126' into 2.3
beberlei Nov 9, 2012
974f18d
Proposed fix for DDC-1241
nemekzg Nov 5, 2012
6fee945
Merge branch 'DDC-1241' into 2.3
beberlei Nov 9, 2012
bbf092c
Fix for invalid 'double-ON' SQL generation with entity inheritance ty…
gws Nov 5, 2012
2229a5e
Merge branch 'DDC-2123' into 2.3
beberlei Nov 9, 2012
9dbf4d8
Allow 0 id for Entity
jeremymarc Nov 5, 2012
045d058
Compare to null instead of using isset
jeremymarc Nov 5, 2012
653aef2
Merge branch 'DDC-2122' into 2.3
beberlei Nov 9, 2012
461d201
notice is thrown up if no identifier values found
Nov 1, 2012
c6118cb
refactoring getIndividualValue for valid key value
Nov 2, 2012
1627c97
Update lib/Doctrine/ORM/Persisters/BasicEntityPersister.php
Nov 3, 2012
edaab11
Merge branch 'DDC-2115' into 2.3
beberlei Nov 9, 2012
95a85d6
Improve DocBlock annotations of generated entities
lanthaler Nov 2, 2012
612ed2b
Merge branch 'DDC-2116' into 2.3
beberlei Nov 9, 2012
6d35fad
[DDC-2113] Surround WHERE clause with parens if using SQLFilter
Nov 1, 2012
2ce877b
Merge branch 'DDC-2113' into 2.3
beberlei Nov 9, 2012
a3c98b1
check for false as a return value from get_parent_class(), not null
Oct 16, 2012
e4ef9e0
Merge branch 'DDC-2082' into 2.3
beberlei Nov 9, 2012
a1094d3
Prevented "Undefined index" notice when updating
Oct 17, 2012
1618a3e
Added testcase for DDC-2086
Oct 19, 2012
3c944b3
Merge branch 'DDC-2086' into 2.3
beberlei Nov 9, 2012
57db88b
Fix DDC-2069
FabioBatSilva Oct 20, 2012
643ed0b
Merge branch 'DDC-2069' into 2.3
beberlei Nov 9, 2012
a7ed9e6
Fix DDC-2079
FabioBatSilva Oct 20, 2012
8c2009c
Fix typo
FabioBatSilva Oct 20, 2012
c6eb04d
Merge branch 'DDC-2079' into 2.3
beberlei Nov 9, 2012
e7e69da
Update lib/Doctrine/ORM/Tools/Pagination/WhereInWalker.php
Oct 12, 2012
ed11e61
Update lib/Doctrine/ORM/Tools/Pagination/Paginator.php
Oct 12, 2012
4ea7a5d
Modified the WhereInWalkerTest to be compatible with a single InputPa…
Nov 6, 2012
d069875
Merge branch 'DDC-2071' into 2.3
beberlei Nov 12, 2012
8865a5b
The distinct query should replicate the fields in order by clause and…
Sep 18, 2012
006d383
extracted pgsql sql generation into a helper method
Nov 12, 2012
5756021
Merge branch 'DDC-1958' into 2.3
beberlei Nov 12, 2012
01148e5
[DDC-2109] Fix bug with ResolveTargetEntityListener and ManyToMany as…
beberlei Nov 12, 2012
77d060a
Merge branch 'DDC-2109' into 2.3
beberlei Nov 12, 2012
24f74bc
regression fix for left joins (double ON)
fran6co Nov 20, 2012
469bd02
added outer left join
fran6co Nov 22, 2012
1aab5fe
Merge branch 'DDC-2158' into 2.3
beberlei Nov 25, 2012
83943e8
[DDC-2074] Added test for PersistentCollection#clear.
Nov 25, 2012
c90ed73
[DDC-2074] Fixed bug regarding clearing PC's without owner
Nov 25, 2012
a3fea32
Merge branch 'DDC-2074' into 2.3
beberlei Nov 25, 2012
45269fe
Fix DDC-2172
FabioBatSilva Nov 27, 2012
faedbfc
refactoring tests
FabioBatSilva Nov 27, 2012
6e7e4dd
Fix CS
FabioBatSilva Nov 27, 2012
f75c3b5
Merge branch 'DDC-2172' into 2.3
beberlei Nov 27, 2012
8613228
Clarify BC break in DDC-2156
beberlei Nov 27, 2012
287b29a
Merge branch 'DDC-2156' into 2.3
beberlei Nov 27, 2012
e0aa01d
Fixed typo
Dec 1, 2012
660f89f
Fixed trailing spaces on SchemaTool
Dec 1, 2012
0672688
Passed column options to the join column
Dec 1, 2012
dab2b50
Merge branch 'DDC-2182' into 2.3
beberlei Dec 4, 2012
de22e72
Update DBAL dependency
beberlei Dec 4, 2012
173b398
Release 2.3.1
beberlei Dec 4, 2012
59aef2c
Bump dev version to 2.3.2
beberlei Dec 4, 2012
f2f8c4f
DDC-2199 / DDC-2192 - Versioned fields didnt work in XML/YAML mapping
beberlei Dec 16, 2012
b666a62
Merge branch 'DDC-2199' into 2.3
beberlei Dec 16, 2012
6d89875
Merge remote-tracking branch 'origin/2.3' into 2.3
beberlei Dec 16, 2012
22dc20c
Fix DDC-1690
PSchwisow Dec 20, 2012
c120700
[DDC-1690] Created unit test
Dec 21, 2012
0425e84
[DDC-1690] Added an empty line as requested.
PSchwisow Dec 21, 2012
b68c6b3
Merge branch 'DDC-1690' into 2.3
beberlei Dec 22, 2012
f94b6c0
Fix MySQL test
beberlei Dec 22, 2012
f05bcbc
[DDC-2206] Fix Setup::registerAutoloadPEAR() to work with Symfony nam…
beberlei Dec 23, 2012
50132dd
Merge branch 'DDC-2206' into 2.3
beberlei Dec 23, 2012
aee75d8
Merge branch '2.3' of github.com:doctrine/doctrine2 into 2.3
beberlei Dec 23, 2012
88e8176
[DDC-2175] Fix bug in JoinedSubclassPersister
beberlei Dec 24, 2012
0190946
Merge branch 'DDC-2175' into 2.3
beberlei Dec 24, 2012
b59cd04
Bump submodule of DBAL to 2.3.2
beberlei Jan 7, 2013
c5725dd
Release 2.3.2
beberlei Jan 7, 2013
f5bb8be
Bump dev version to 2.3.3
beberlei Jan 7, 2013
c4c70d6
The EntityManager was not injected in uninitialized proxys which are …
Jan 10, 2013
8001cad
fixed indentation
Jan 10, 2013
54193e7
Added test
Jan 10, 2013
fc2eebd
DDC-2231 - Simplify test
beberlei Jan 12, 2013
6829c46
Merge branch 'DDC-2231' into 2.3
beberlei Jan 12, 2013
88cebe1
[DDC-2246] Fix bug with UnitOfWork#getEntityState() and entities with…
beberlei Jan 20, 2013
d9f51eb
Merge branch 'DDC-2246' into 2.3
beberlei Jan 20, 2013
6d25c4e
Merge remote-tracking branch 'origin/2.3' into 2.3
beberlei Jan 20, 2013
f0312ed
[DDC-2243] Fix bug where a bigint identifier would be casted to an in…
beberlei Jan 20, 2013
fdd0af3
Merge branch 'DDC-2243' into 2.3
beberlei Jan 20, 2013
05830da
make it possible to add class or instance to addFilter
gimler Jan 26, 2013
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions UPGRADE.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,13 @@
# Upgrade to 2.3

## EntityManager#find() not calls EntityRepository#find() anymore

Previous to 2.3, calling ``EntityManager#find()`` would be delegated to
``EntityRepository#find()``. This has lead to some unexpected behavior in the
core of Doctrine when people have overwritten the find method in their
repositories. That is why this behavior has been reversed in 2.3, and
``EntityRepository#find()`` calls ``EntityManager#find()`` instead.

## EntityGenerator add*() method generation

When generating an add*() method for a collection the EntityGenerator will now not
Expand Down
4 changes: 2 additions & 2 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
"require": {
"php": ">=5.3.2",
"ext-pdo": "*",
"doctrine/dbal": ">=2.3-dev,<2.5-dev",
"doctrine/dbal": "2.3.*",
"symfony/console": "2.*"
},
"suggest": {
Expand All @@ -26,7 +26,7 @@
"bin": ["bin/doctrine", "bin/doctrine.php"],
"extra": {
"branch-alias": {
"dev-master": "2.4.x-dev"
"dev-master": "2.3.x-dev"
}
}
}
2 changes: 1 addition & 1 deletion lib/Doctrine/ORM/AbstractQuery.php
Original file line number Diff line number Diff line change
Expand Up @@ -281,7 +281,7 @@ private function convertObjectParameterToScalarValue($value)

$value = $values[$class->getSingleIdentifierFieldName()];

if ( ! $value) {
if (null === $value) {
throw new \InvalidArgumentException(
"Binding entities to query parameters only allowed for entities that have an identifier."
);
Expand Down
6 changes: 3 additions & 3 deletions lib/Doctrine/ORM/Configuration.php
Original file line number Diff line number Diff line change
Expand Up @@ -584,14 +584,14 @@ public function addFilter($name, $className)
}

/**
* Gets the class name for a given filter name.
* Gets the filter for a given name.
*
* @param string $name The name of the filter.
*
* @return string The class name of the filter, or null of it is not
* @return string|SQLFilter|null The class name or instance of the filter, or null of it is not
* defined.
*/
public function getFilterClassName($name)
public function getFilter($name)
{
return isset($this->_attributes['filters'][$name])
? $this->_attributes['filters'][$name]
Expand Down
8 changes: 5 additions & 3 deletions lib/Doctrine/ORM/EntityRepository.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
use Doctrine\Common\Collections\Selectable;
use Doctrine\Common\Collections\Criteria;
use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\Common\Collections\ExpressionBuilder;

/**
* An EntityRepository serves as a repository for entities with generic as well as
Expand Down Expand Up @@ -160,13 +161,14 @@ public function findBy(array $criteria, array $orderBy = null, $limit = null, $o
* Finds a single entity by a set of criteria.
*
* @param array $criteria
* @param array|null $orderBy
* @return object
*/
public function findOneBy(array $criteria)
public function findOneBy(array $criteria, array $orderBy = null)
{
$persister = $this->_em->getUnitOfWork()->getEntityPersister($this->_entityName);

return $persister->load($criteria, null, null, array(), 0, 1);
return $persister->load($criteria, null, null, array(), 0, 1, $orderBy);
}

/**
Expand Down Expand Up @@ -214,7 +216,7 @@ public function __call($method, $arguments)
case 3:
return $this->$method(array($fieldName => $arguments[0]), $arguments[1], $arguments[2]);

case 4;
case 4:
return $this->$method(array($fieldName => $arguments[0]), $arguments[1], $arguments[2], $arguments[3]);

default:
Expand Down
66 changes: 66 additions & 0 deletions lib/Doctrine/ORM/Id/BigIntegerIdentityGenerator.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
<?php
/*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
* This software consists of voluntary contributions made by many individuals
* and is licensed under the MIT license. For more information, see
* <http://www.doctrine-project.org>.
*/

namespace Doctrine\ORM\Id;

use Doctrine\ORM\EntityManager;

/**
* Id generator that obtains IDs from special "identity" columns. These are columns
* that automatically get a database-generated, auto-incremented identifier on INSERT.
* This generator obtains the last insert id after such an insert.
*/
class BigIntegerIdentityGenerator extends AbstractIdGenerator
{
/**
* The name of the sequence to pass to lastInsertId(), if any.
*
* @var string
*/
private $sequenceName;

/**
* Constructor.
*
* @param string|null $seqName The name of the sequence to pass to lastInsertId()
* to obtain the last generated identifier within the current
* database session/connection, if any.
*/
public function __construct($sequenceName = null)
{
$this->sequenceName = $sequenceName;
}

/**
* {@inheritdoc}
*/
public function generate(EntityManager $em, $entity)
{
return (string)$em->getConnection()->lastInsertId($this->sequenceName);
}

/**
* {@inheritdoc}
*/
public function isPostInsertGenerator()
{
return true;
}
}

14 changes: 9 additions & 5 deletions lib/Doctrine/ORM/Id/IdentityGenerator.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,25 +28,29 @@
*/
class IdentityGenerator extends AbstractIdGenerator
{
/** @var string The name of the sequence to pass to lastInsertId(), if any. */
private $_seqName;
/**
* The name of the sequence to pass to lastInsertId(), if any.
*
* @var string
*/
private $sequenceName;

/**
* @param string $seqName The name of the sequence to pass to lastInsertId()
* to obtain the last generated identifier within the current
* database session/connection, if any.
*/
public function __construct($seqName = null)
public function __construct($sequenceName = null)
{
$this->_seqName = $seqName;
$this->sequenceName = $sequenceName;
}

/**
* {@inheritdoc}
*/
public function generate(EntityManager $em, $entity)
{
return (int)$em->getConnection()->lastInsertId($this->_seqName);
return (int)$em->getConnection()->lastInsertId($this->sequenceName);
}

/**
Expand Down
30 changes: 18 additions & 12 deletions lib/Doctrine/ORM/Mapping/ClassMetadataFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,16 +19,17 @@

namespace Doctrine\ORM\Mapping;

use ReflectionException,
Doctrine\ORM\ORMException,
Doctrine\ORM\EntityManager,
Doctrine\DBAL\Platforms,
Doctrine\ORM\Events,
Doctrine\Common\Persistence\Mapping\ReflectionService,
Doctrine\Common\Persistence\Mapping\ClassMetadata as ClassMetadataInterface,
Doctrine\Common\Persistence\Mapping\AbstractClassMetadataFactory,
Doctrine\ORM\Id\IdentityGenerator,
Doctrine\ORM\Event\LoadClassMetadataEventArgs;
use ReflectionException;
use Doctrine\ORM\ORMException;
use Doctrine\ORM\EntityManager;
use Doctrine\DBAL\Platforms;
use Doctrine\ORM\Events;
use Doctrine\Common\Persistence\Mapping\ReflectionService;
use Doctrine\Common\Persistence\Mapping\ClassMetadata as ClassMetadataInterface;
use Doctrine\Common\Persistence\Mapping\AbstractClassMetadataFactory;
use Doctrine\ORM\Id\IdentityGenerator;
use Doctrine\ORM\Id\BigIntegerIdentityGenerator;
use Doctrine\ORM\Event\LoadClassMetadataEventArgs;

/**
* The ClassMetadataFactory is used to create ClassMetadata objects that contain all the
Expand Down Expand Up @@ -418,9 +419,9 @@ private function completeIdGeneratorMapping(ClassMetadataInfo $class)
// <table>_<column>_seq in PostgreSQL for SERIAL columns.
// Not pretty but necessary and the simplest solution that currently works.
$sequenceName = null;
$fieldName = $class->identifier ? $class->getSingleIdentifierFieldName() : null;

if ($this->targetPlatform instanceof Platforms\PostgreSQLPlatform) {
$fieldName = $class->getSingleIdentifierFieldName();
$columnName = $class->getSingleIdentifierColumnName();
$quoted = isset($class->fieldMappings[$fieldName]['quoted']) || isset($class->table['quoted']);
$sequenceName = $class->getTableName() . '_' . $columnName . '_seq';
Expand All @@ -435,7 +436,12 @@ private function completeIdGeneratorMapping(ClassMetadataInfo $class)
$sequenceName = $this->em->getConfiguration()->getQuoteStrategy()->getSequenceName($definition, $class, $this->targetPlatform);
}

$class->setIdGenerator(new \Doctrine\ORM\Id\IdentityGenerator($sequenceName));
$generator = ($fieldName && $class->fieldMappings[$fieldName]['type'] === "bigint")
? new BigIntegerIdentityGenerator($sequenceName)
: new IdentityGenerator($sequenceName);

$class->setIdGenerator($generator);

break;

case ClassMetadata::GENERATOR_TYPE_SEQUENCE:
Expand Down
7 changes: 4 additions & 3 deletions lib/Doctrine/ORM/Mapping/ClassMetadataInfo.php
Original file line number Diff line number Diff line change
Expand Up @@ -1188,7 +1188,7 @@ protected function _validateAndCompleteFieldMapping(array &$mapping)

// Complete fieldName and columnName mapping
if ( ! isset($mapping['columnName'])) {
$mapping['columnName'] = $this->namingStrategy->propertyToColumnName($mapping['fieldName'], $this->name);
$mapping['columnName'] = $this->namingStrategy->propertyToColumnName($mapping['fieldName']);
}

if ($mapping['columnName'][0] === '`') {
Expand Down Expand Up @@ -1465,7 +1465,6 @@ protected function _validateAndCompleteManyToManyMapping(array $mapping)
if ( ! isset($mapping['joinTable']['name'])) {
$mapping['joinTable']['name'] = $this->namingStrategy->joinTableName($mapping['sourceEntity'], $mapping['targetEntity'], $mapping['fieldName']);
}

if ( ! isset($mapping['joinTable']['joinColumns'])) {
$mapping['joinTable']['joinColumns'] = array(array(
'name' => $this->namingStrategy->joinKeyColumnName($mapping['sourceEntity']),
Expand All @@ -1479,6 +1478,8 @@ protected function _validateAndCompleteManyToManyMapping(array $mapping)
'onDelete' => 'CASCADE'));
}

$mapping['joinTableColumns'] = array();

foreach ($mapping['joinTable']['joinColumns'] as &$joinColumn) {
if (empty($joinColumn['name'])) {
$joinColumn['name'] = $this->namingStrategy->joinKeyColumnName($mapping['sourceEntity'], $joinColumn['referencedColumnName']);
Expand Down Expand Up @@ -2725,7 +2726,7 @@ public function getQuotedIdentifierColumnNames($platform)
// Association defined as Id field
$joinColumns = $this->associationMappings[$idProperty]['joinColumns'];
$assocQuotedColumnNames = array_map(
function ($joinColumn) {
function ($joinColumn) use ($platform) {
return isset($joinColumn['quoted'])
? $platform->quoteIdentifier($joinColumn['name'])
: $joinColumn['name'];
Expand Down
2 changes: 1 addition & 1 deletion lib/Doctrine/ORM/Mapping/DefaultNamingStrategy.php
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ public function classToTableName($className)
/**
* {@inheritdoc}
*/
public function propertyToColumnName($propertyName, $className = null)
public function propertyToColumnName($propertyName)
{
return $propertyName;
}
Expand Down
37 changes: 0 additions & 37 deletions lib/Doctrine/ORM/Mapping/Driver/AnnotationDriver.php
Original file line number Diff line number Diff line change
Expand Up @@ -197,43 +197,6 @@ public function loadMetadataForClass($className, ClassMetadata $metadata)
}
}

$associationOverrides = array();
// Evaluate AssociationOverrides annotation
if (isset($classAnnotations['Doctrine\ORM\Mapping\AssociationOverrides'])) {
$associationOverridesAnnot = $classAnnotations['Doctrine\ORM\Mapping\AssociationOverrides'];

foreach ($associationOverridesAnnot->value as $associationOverride) {
// Check for JoinColummn/JoinColumns annotations
if ($associationOverride->joinColumns) {
$joinColumns = array();
foreach ($associationOverride->joinColumns as $joinColumn) {
$joinColumns[] = $this->joinColumnToArray($joinColumn);
}
$associationOverrides[$associationOverride->name]['joinColumns'] = $joinColumns;
}

// Check for JoinTable annotations
if ($associationOverride->joinTable) {
$joinTable = null;
$joinTableAnnot = $associationOverride->joinTable;
$joinTable = array(
'name' => $joinTableAnnot->name,
'schema' => $joinTableAnnot->schema
);

foreach ($joinTableAnnot->joinColumns as $joinColumn) {
$joinTable['joinColumns'][] = $this->joinColumnToArray($joinColumn);
}

foreach ($joinTableAnnot->inverseJoinColumns as $joinColumn) {
$joinTable['inverseJoinColumns'][] = $this->joinColumnToArray($joinColumn);
}

$associationOverrides[$associationOverride->name]['joinTable'] = $joinTable;
}
}
}

// Evaluate InheritanceType annotation
if (isset($classAnnotations['Doctrine\ORM\Mapping\InheritanceType'])) {
$inheritanceTypeAnnot = $classAnnotations['Doctrine\ORM\Mapping\InheritanceType'];
Expand Down
4 changes: 4 additions & 0 deletions lib/Doctrine/ORM/Mapping/Driver/DatabaseDriver.php
Original file line number Diff line number Diff line change
Expand Up @@ -297,6 +297,10 @@ public function loadMetadataForClass($className, ClassMetadata $metadata)
$associationMapping['fieldName'] = $this->getFieldNameForColumn($tableName, $localColumn, true);
$associationMapping['targetEntity'] = $this->getClassNameForTable($foreignTable);

if (isset($metadata->fieldMappings[$associationMapping['fieldName']])) {
$associationMapping['fieldName'] = $associationMapping['fieldName'] . "2";
}

if ($primaryKeyColumns && in_array($localColumn, $primaryKeyColumns)) {
$associationMapping['id'] = true;
}
Expand Down
Loading