Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
D
doctrine-dbal
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Tomáš Trávníček
doctrine-dbal
Commits
71c1fe52
Commit
71c1fe52
authored
Oct 06, 2009
by
romanb
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[2.0][DDC-2] Fixed.
parent
bda1b9ae
Changes
4
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
57 additions
and
5 deletions
+57
-5
ObjectHydrator.php
lib/Doctrine/ORM/Internal/Hydration/ObjectHydrator.php
+10
-3
UnitOfWork.php
lib/Doctrine/ORM/UnitOfWork.php
+4
-1
OneToOneBidirectionalAssociationTest.php
...s/ORM/Functional/OneToOneBidirectionalAssociationTest.php
+41
-1
OrmFunctionalTestCase.php
tests/Doctrine/Tests/OrmFunctionalTestCase.php
+2
-0
No files found.
lib/Doctrine/ORM/Internal/Hydration/ObjectHydrator.php
View file @
71c1fe52
...
@@ -49,6 +49,7 @@ class ObjectHydrator extends AbstractHydrator
...
@@ -49,6 +49,7 @@ class ObjectHydrator extends AbstractHydrator
private
$_fetchedAssociations
;
private
$_fetchedAssociations
;
private
$_rootAliases
=
array
();
private
$_rootAliases
=
array
();
private
$_initializedCollections
=
array
();
private
$_initializedCollections
=
array
();
private
$_proxyFactory
;
/** @override */
/** @override */
protected
function
_prepare
()
protected
function
_prepare
()
...
@@ -56,6 +57,10 @@ class ObjectHydrator extends AbstractHydrator
...
@@ -56,6 +57,10 @@ class ObjectHydrator extends AbstractHydrator
$this
->
_allowPartialObjects
=
$this
->
_em
->
getConfiguration
()
->
getAllowPartialObjects
()
$this
->
_allowPartialObjects
=
$this
->
_em
->
getConfiguration
()
->
getAllowPartialObjects
()
||
isset
(
$this
->
_hints
[
Query
::
HINT_FORCE_PARTIAL_LOAD
]);
||
isset
(
$this
->
_hints
[
Query
::
HINT_FORCE_PARTIAL_LOAD
]);
if
(
!
$this
->
_allowPartialObjects
)
{
$this
->
_proxyFactory
=
$this
->
_em
->
getProxyFactory
();
}
$this
->
_identifierMap
=
$this
->
_identifierMap
=
$this
->
_resultPointers
=
$this
->
_resultPointers
=
$this
->
_idTemplate
=
$this
->
_idTemplate
=
...
@@ -184,6 +189,7 @@ class ObjectHydrator extends AbstractHydrator
...
@@ -184,6 +189,7 @@ class ObjectHydrator extends AbstractHydrator
// Properly initialize any unfetched associations, if partial objects are not allowed.
// Properly initialize any unfetched associations, if partial objects are not allowed.
if
(
!
$this
->
_allowPartialObjects
)
{
if
(
!
$this
->
_allowPartialObjects
)
{
$oid
=
spl_object_hash
(
$entity
);
foreach
(
$this
->
_getClassMetadata
(
$className
)
->
associationMappings
as
$field
=>
$assoc
)
{
foreach
(
$this
->
_getClassMetadata
(
$className
)
->
associationMappings
as
$field
=>
$assoc
)
{
// Check if the association is not among the fetch-joined associatons already.
// Check if the association is not among the fetch-joined associatons already.
if
(
!
isset
(
$this
->
_fetchedAssociations
[
$className
][
$field
]))
{
if
(
!
isset
(
$this
->
_fetchedAssociations
[
$className
][
$field
]))
{
...
@@ -194,9 +200,9 @@ class ObjectHydrator extends AbstractHydrator
...
@@ -194,9 +200,9 @@ class ObjectHydrator extends AbstractHydrator
}
}
if
(
$assoc
->
isLazilyFetched
())
{
if
(
$assoc
->
isLazilyFetched
())
{
// Inject proxy
// Inject proxy
$
this
->
_ce
[
$className
]
->
reflFields
[
$field
]
->
setValue
(
$entity
,
$
proxy
=
$this
->
_proxyFactory
->
getAssociationProxy
(
$entity
,
$assoc
,
$joinColumns
);
$this
->
_em
->
getProxyFactory
()
->
getAssociationProxy
(
$entity
,
$assoc
,
$joinColumns
)
$this
->
_uow
->
setOriginalEntityProperty
(
$oid
,
$field
,
$proxy
);
);
$this
->
_ce
[
$className
]
->
reflFields
[
$field
]
->
setValue
(
$entity
,
$proxy
);
}
else
{
}
else
{
// Eager load
// Eager load
//TODO: Allow more efficient and configurable batching of these loads
//TODO: Allow more efficient and configurable batching of these loads
...
@@ -217,6 +223,7 @@ class ObjectHydrator extends AbstractHydrator
...
@@ -217,6 +223,7 @@ class ObjectHydrator extends AbstractHydrator
//TODO: Allow more efficient and configurable batching of these loads
//TODO: Allow more efficient and configurable batching of these loads
$assoc
->
load
(
$entity
,
$pColl
,
$this
->
_em
);
$assoc
->
load
(
$entity
,
$pColl
,
$this
->
_em
);
}
}
$this
->
_uow
->
setOriginalEntityProperty
(
$oid
,
$field
,
$pColl
);
}
}
}
}
}
}
...
...
lib/Doctrine/ORM/UnitOfWork.php
View file @
71c1fe52
...
@@ -598,6 +598,9 @@ class UnitOfWork implements PropertyChangedListener
...
@@ -598,6 +598,9 @@ class UnitOfWork implements PropertyChangedListener
* Computes the changeset of an individual entity, independently of the
* Computes the changeset of an individual entity, independently of the
* computeChangeSets() routine that is used at the beginning of a UnitOfWork#commit().
* computeChangeSets() routine that is used at the beginning of a UnitOfWork#commit().
*
*
* The passed entity must be a managed entity.
*
* @ignore
* @param $class
* @param $class
* @param $entity
* @param $entity
*/
*/
...
@@ -1381,7 +1384,7 @@ class UnitOfWork implements PropertyChangedListener
...
@@ -1381,7 +1384,7 @@ class UnitOfWork implements PropertyChangedListener
$this
->
removeFromIdentityMap
(
$entity
);
$this
->
removeFromIdentityMap
(
$entity
);
unset
(
$this
->
_entityInsertions
[
$oid
],
$this
->
_entityUpdates
[
$oid
],
unset
(
$this
->
_entityInsertions
[
$oid
],
$this
->
_entityUpdates
[
$oid
],
$this
->
_entityDeletions
[
$oid
],
$this
->
_entityIdentifiers
[
$oid
],
$this
->
_entityDeletions
[
$oid
],
$this
->
_entityIdentifiers
[
$oid
],
$this
->
_entityStates
[
$oid
]);
$this
->
_entityStates
[
$oid
]
,
$this
->
_originalEntityData
[
$oid
]
);
break
;
break
;
case
self
::
STATE_NEW
:
case
self
::
STATE_NEW
:
case
self
::
STATE_DETACHED
:
case
self
::
STATE_DETACHED
:
...
...
tests/Doctrine/Tests/ORM/Functional/OneToOneBidirectionalAssociationTest.php
View file @
71c1fe52
...
@@ -79,7 +79,8 @@ class OneToOneBidirectionalAssociationTest extends \Doctrine\Tests\OrmFunctional
...
@@ -79,7 +79,8 @@ class OneToOneBidirectionalAssociationTest extends \Doctrine\Tests\OrmFunctional
$this
->
assertEquals
(
'Giorgio'
,
$cart
->
getCustomer
()
->
getName
());
$this
->
assertEquals
(
'Giorgio'
,
$cart
->
getCustomer
()
->
getName
());
}
}
public
function
testLazyLoadsObjectsOnTheInverseSide
()
{
public
function
testLazyLoadsObjectsOnTheInverseSide
()
{
$this
->
_createFixture
();
$this
->
_createFixture
();
$this
->
_em
->
getConfiguration
()
->
setAllowPartialObjects
(
false
);
$this
->
_em
->
getConfiguration
()
->
setAllowPartialObjects
(
false
);
$metadata
=
$this
->
_em
->
getClassMetadata
(
'Doctrine\Tests\Models\ECommerce\ECommerceCustomer'
);
$metadata
=
$this
->
_em
->
getClassMetadata
(
'Doctrine\Tests\Models\ECommerce\ECommerceCustomer'
);
...
@@ -94,6 +95,45 @@ class OneToOneBidirectionalAssociationTest extends \Doctrine\Tests\OrmFunctional
...
@@ -94,6 +95,45 @@ class OneToOneBidirectionalAssociationTest extends \Doctrine\Tests\OrmFunctional
$this
->
assertEquals
(
'paypal'
,
$customer
->
getCart
()
->
getPayment
());
$this
->
assertEquals
(
'paypal'
,
$customer
->
getCart
()
->
getPayment
());
}
}
public
function
testUpdateWithProxyObject
()
{
$this
->
_em
->
getConfiguration
()
->
setAllowPartialObjects
(
false
);
$cust
=
new
ECommerceCustomer
;
$cust
->
setName
(
'Roman'
);
$cart
=
new
ECommerceCart
;
$cart
->
setPayment
(
'CARD'
);
$cust
->
setCart
(
$cart
);
$this
->
_em
->
persist
(
$cust
);
$this
->
_em
->
flush
();
$this
->
_em
->
clear
();
$this
->
assertTrue
(
$cust
->
getCart
()
instanceof
ECommerceCart
);
$this
->
assertEquals
(
'Roman'
,
$cust
->
getName
());
$this
->
assertSame
(
$cust
,
$cart
->
getCustomer
());
$query
=
$this
->
_em
->
createQuery
(
'select ca from Doctrine\Tests\Models\ECommerce\ECommerceCart ca where ca.id =?1'
);
$query
->
setParameter
(
1
,
$cart
->
getId
());
$cart2
=
$query
->
getSingleResult
();
$cart2
->
setPayment
(
'CHEQUE'
);
$this
->
_em
->
flush
();
$this
->
_em
->
clear
();
$query2
=
$this
->
_em
->
createQuery
(
'select ca, c from Doctrine\Tests\Models\ECommerce\ECommerceCart ca left join ca.customer c where ca.id =?1'
);
$query2
->
setParameter
(
1
,
$cart
->
getId
());
$cart3
=
$query2
->
getSingleResult
();
$this
->
assertTrue
(
$cart3
->
getCustomer
()
instanceof
ECommerceCustomer
);
$this
->
assertEquals
(
'Roman'
,
$cart3
->
getCustomer
()
->
getName
());
$this
->
_em
->
getConfiguration
()
->
setAllowPartialObjects
(
true
);
}
protected
function
_createFixture
()
protected
function
_createFixture
()
{
{
$customer
=
new
ECommerceCustomer
;
$customer
=
new
ECommerceCustomer
;
...
...
tests/Doctrine/Tests/OrmFunctionalTestCase.php
View file @
71c1fe52
...
@@ -162,6 +162,8 @@ class OrmFunctionalTestCase extends OrmTestCase
...
@@ -162,6 +162,8 @@ class OrmFunctionalTestCase extends OrmTestCase
if
(
is_null
(
self
::
$_queryCacheImpl
))
{
if
(
is_null
(
self
::
$_queryCacheImpl
))
{
self
::
$_queryCacheImpl
=
new
\Doctrine\Common\Cache\ArrayCache
;
self
::
$_queryCacheImpl
=
new
\Doctrine\Common\Cache\ArrayCache
;
}
}
//FIXME: two different configs! $conn and the created entity manager have
// different configs.
$config
=
new
\Doctrine\ORM\Configuration
();
$config
=
new
\Doctrine\ORM\Configuration
();
$config
->
setMetadataCacheImpl
(
self
::
$_metadataCacheImpl
);
$config
->
setMetadataCacheImpl
(
self
::
$_metadataCacheImpl
);
$config
->
setQueryCacheImpl
(
self
::
$_queryCacheImpl
);
$config
->
setQueryCacheImpl
(
self
::
$_queryCacheImpl
);
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment