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
124cbe90
Commit
124cbe90
authored
Nov 15, 2009
by
romanb
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[2.0][DDC-137] Fixed.
parent
c3ef0195
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
64 additions
and
3 deletions
+64
-3
UnitOfWork.php
lib/Doctrine/ORM/UnitOfWork.php
+12
-3
OneToOneSelfReferentialAssociationTest.php
...ORM/Functional/OneToOneSelfReferentialAssociationTest.php
+52
-0
No files found.
lib/Doctrine/ORM/UnitOfWork.php
View file @
124cbe90
...
...
@@ -903,13 +903,21 @@ class UnitOfWork implements PropertyChangedListener
* Schedules an extra update that will be executed immediately after the
* regular entity updates within the currently running commit cycle.
*
* Extra updates for entities are stored as (entity, changeset) tuples.
*
* @ignore
* @param
$entity
* @param
$changeset
* @param
object $entity The entity for which to schedule an extra update.
* @param
array $changeset The changeset of the entity (what to update).
*/
public
function
scheduleExtraUpdate
(
$entity
,
array
$changeset
)
{
$this
->
_extraUpdates
[
spl_object_hash
(
$entity
)]
=
array
(
$entity
,
$changeset
);
$oid
=
spl_object_hash
(
$entity
);
if
(
isset
(
$this
->
_extraUpdates
[
$oid
]))
{
list
(
$ignored
,
$changeset2
)
=
$this
->
_extraUpdates
[
$oid
];
$this
->
_extraUpdates
[
$oid
]
=
array
(
$entity
,
$changeset
+
$changeset2
);
}
else
{
$this
->
_extraUpdates
[
$oid
]
=
array
(
$entity
,
$changeset
);
}
}
/**
...
...
@@ -1638,6 +1646,7 @@ class UnitOfWork implements PropertyChangedListener
$this
->
_entityDeletions
=
$this
->
_collectionDeletions
=
$this
->
_collectionUpdates
=
$this
->
_extraUpdates
=
$this
->
_orphanRemovals
=
array
();
$this
->
_commitOrderCalculator
->
clear
();
}
...
...
tests/Doctrine/Tests/ORM/Functional/OneToOneSelfReferentialAssociationTest.php
View file @
124cbe90
...
...
@@ -74,6 +74,34 @@ class OneToOneSelfReferentialAssociationTest extends \Doctrine\Tests\OrmFunction
$customer
=
$result
[
0
];
$this
->
assertLoadingOfAssociation
(
$customer
);
}
public
function
testMultiSelfReference
()
{
try
{
$this
->
_schemaTool
->
createSchema
(
array
(
$this
->
_em
->
getClassMetadata
(
'Doctrine\Tests\ORM\Functional\MultiSelfReference'
)
));
}
catch
(
\Exception
$e
)
{
// Swallow all exceptions. We do not test the schema tool here.
}
$entity1
=
new
MultiSelfReference
();
$this
->
_em
->
persist
(
$entity1
);
$entity1
->
setOther1
(
$entity2
=
new
MultiSelfReference
);
$entity1
->
setOther2
(
$entity3
=
new
MultiSelfReference
);
$this
->
_em
->
flush
();
$this
->
_em
->
clear
();
$entity2
=
$this
->
_em
->
find
(
get_class
(
$entity1
),
$entity1
->
getId
());
$this
->
assertTrue
(
$entity2
->
getOther1
()
instanceof
MultiSelfReference
);
$this
->
assertTrue
(
$entity2
->
getOther2
()
instanceof
MultiSelfReference
);
$this
->
assertNull
(
$entity2
->
getOther1
()
->
getOther1
());
$this
->
assertNull
(
$entity2
->
getOther1
()
->
getOther2
());
$this
->
assertNull
(
$entity2
->
getOther2
()
->
getOther1
());
$this
->
assertNull
(
$entity2
->
getOther2
()
->
getOther2
());
}
public
function
assertLoadingOfAssociation
(
$customer
)
{
...
...
@@ -100,3 +128,27 @@ class OneToOneSelfReferentialAssociationTest extends \Doctrine\Tests\OrmFunction
$this
->
_em
->
clear
();
}
}
/**
* @Entity
*/
class
MultiSelfReference
{
/** @Id @GeneratedValue(strategy="AUTO") @Column(type="integer") */
private
$id
;
/**
* @OneToOne(targetEntity="MultiSelfReference", cascade={"persist"})
* @JoinColumn(name="other1", referencedColumnName="id")
*/
private
$other1
;
/**
* @OneToOne(targetEntity="MultiSelfReference", cascade={"persist"})
* @JoinColumn(name="other2", referencedColumnName="id")
*/
private
$other2
;
public
function
getId
()
{
return
$this
->
id
;}
public
function
setOther1
(
$other1
)
{
$this
->
other1
=
$other1
;}
public
function
getOther1
()
{
return
$this
->
other1
;}
public
function
setOther2
(
$other2
)
{
$this
->
other2
=
$other2
;}
public
function
getOther2
()
{
return
$this
->
other2
;}
}
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