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
3d3bcc17
Commit
3d3bcc17
authored
Sep 15, 2009
by
romanb
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[2.0][DDC-7] Fixed.
parent
7ef91a64
Changes
9
Hide whitespace changes
Inline
Side-by-side
Showing
9 changed files
with
177 additions
and
17 deletions
+177
-17
PersistentCollection.php
lib/Doctrine/ORM/PersistentCollection.php
+0
-1
JoinedSubclassPersister.php
lib/Doctrine/ORM/Persisters/JoinedSubclassPersister.php
+11
-4
StandardEntityPersister.php
lib/Doctrine/ORM/Persisters/StandardEntityPersister.php
+9
-8
CompanyAuction.php
tests/Doctrine/Tests/Models/Company/CompanyAuction.php
+17
-0
CompanyEvent.php
tests/Doctrine/Tests/Models/Company/CompanyEvent.php
+35
-0
CompanyOrganization.php
tests/Doctrine/Tests/Models/Company/CompanyOrganization.php
+30
-0
CompanyRaffle.php
tests/Doctrine/Tests/Models/Company/CompanyRaffle.php
+17
-0
ClassTableInheritanceTest.php
...ctrine/Tests/ORM/Functional/ClassTableInheritanceTest.php
+49
-3
OrmFunctionalTestCase.php
tests/Doctrine/Tests/OrmFunctionalTestCase.php
+9
-1
No files found.
lib/Doctrine/ORM/PersistentCollection.php
View file @
3d3bcc17
...
...
@@ -294,7 +294,6 @@ final class PersistentCollection implements \Doctrine\Common\Collections\Collect
{
return
$this
->
_association
;
}
/**
* Marks this collection as changed/dirty.
...
...
lib/Doctrine/ORM/Persisters/JoinedSubclassPersister.php
View file @
3d3bcc17
...
...
@@ -269,10 +269,9 @@ class JoinedSubclassPersister extends StandardEntityPersister
*
* @param array $criteria
* @return string The SQL.
* @todo Quote identifier.
* @override
*/
protected
function
_getSelectEntitiesSql
(
array
&
$criteria
)
protected
function
_getSelectEntitiesSql
(
array
&
$criteria
,
$assoc
=
null
)
{
$tableAliases
=
array
();
$aliasIndex
=
1
;
...
...
@@ -286,7 +285,7 @@ class JoinedSubclassPersister extends StandardEntityPersister
$columnList
=
''
;
foreach
(
$this
->
_class
->
fieldMappings
as
$fieldName
=>
$mapping
)
{
$tableAlias
=
isset
(
$mapping
[
'inherited'
])
?
$tableAliases
[
$mapping
[
'inherited'
]]
:
$baseTableAlias
;
$tableAliases
[
$mapping
[
'inherited'
]]
:
$baseTableAlias
;
if
(
$columnList
!=
''
)
$columnList
.=
', '
;
$columnList
.=
$tableAlias
.
'.'
.
$this
->
_class
->
getQuotedColumnName
(
$fieldName
,
$this
->
_platform
);
}
...
...
@@ -329,7 +328,15 @@ class JoinedSubclassPersister extends StandardEntityPersister
$conditionSql
=
''
;
foreach
(
$criteria
as
$field
=>
$value
)
{
if
(
$conditionSql
!=
''
)
$conditionSql
.=
' AND '
;
$conditionSql
.=
$baseTableAlias
.
'.'
.
$this
->
_class
->
columnNames
[
$field
]
.
' = ?'
;
$conditionSql
.=
$baseTableAlias
.
'.'
;
if
(
isset
(
$this
->
_class
->
columnNames
[
$field
]))
{
$conditionSql
.=
$this
->
_class
->
getQuotedColumnName
(
$field
,
$this
->
_platform
);
}
else
if
(
$assoc
!==
null
)
{
$conditionSql
.=
$assoc
->
getQuotedJoinColumnName
(
$field
,
$this
->
_platform
);
}
else
{
throw
DoctrineException
::
unrecognizedField
(
$field
);
}
$conditionSql
.=
' = ?'
;
}
return
$sql
.
(
$conditionSql
!=
''
?
' WHERE '
.
$conditionSql
:
''
);
...
...
lib/Doctrine/ORM/Persisters/StandardEntityPersister.php
View file @
3d3bcc17
...
...
@@ -452,12 +452,13 @@ class StandardEntityPersister
* @param array $criteria The criteria by which to select the entities.
* @param PersistentCollection The collection to fill.
*/
public
function
loadOneToManyCollection
(
array
$criteria
,
PersistentCollection
$coll
ection
)
public
function
loadOneToManyCollection
(
array
$criteria
,
PersistentCollection
$coll
)
{
$stmt
=
$this
->
_conn
->
prepare
(
$this
->
_getSelectEntitiesSql
(
$criteria
));
$owningAssoc
=
$this
->
_class
->
associationMappings
[
$coll
->
getMapping
()
->
mappedByFieldName
];
$stmt
=
$this
->
_conn
->
prepare
(
$this
->
_getSelectEntitiesSql
(
$criteria
,
$owningAssoc
));
$stmt
->
execute
(
array_values
(
$criteria
));
while
(
$result
=
$stmt
->
fetch
(
Connection
::
FETCH_ASSOC
))
{
$coll
ection
->
hydrateAdd
(
$this
->
_createEntity
(
$result
));
$coll
->
hydrateAdd
(
$this
->
_createEntity
(
$result
));
}
$stmt
->
closeCursor
();
}
...
...
@@ -565,7 +566,7 @@ class StandardEntityPersister
* @param array $criteria
* @return string The SQL.
*/
protected
function
_getSelectEntitiesSql
(
array
&
$criteria
)
protected
function
_getSelectEntitiesSql
(
array
&
$criteria
,
$assoc
=
null
)
{
$columnList
=
''
;
foreach
(
$this
->
_class
->
fieldNames
as
$field
)
{
...
...
@@ -593,13 +594,13 @@ class StandardEntityPersister
}
if
(
isset
(
$this
->
_class
->
columnNames
[
$field
]))
{
$co
lumnName
=
$this
->
_class
->
getQuotedColumnName
(
$field
,
$this
->
_platform
);
}
else
if
(
in_array
(
$field
,
$joinColumnNames
)
)
{
$co
lumnName
=
$field
;
$co
nditionSql
.
=
$this
->
_class
->
getQuotedColumnName
(
$field
,
$this
->
_platform
);
}
else
if
(
$assoc
!==
null
)
{
$co
nditionSql
.=
$assoc
->
getQuotedJoinColumnName
(
$field
,
$this
->
_platform
)
;
}
else
{
throw
DoctrineException
::
unrecognizedField
(
$field
);
}
$conditionSql
.=
$columnName
.
' = ?'
;
$conditionSql
.=
' = ?'
;
}
return
'SELECT '
.
$columnList
...
...
tests/Doctrine/Tests/Models/Company/CompanyAuction.php
0 → 100644
View file @
3d3bcc17
<?php
namespace
Doctrine\Tests\Models\Company
;
/** @Entity @Table(name="company_auctions") */
class
CompanyAuction
extends
CompanyEvent
{
/** @Column(type="string") */
private
$data
;
public
function
setData
(
$data
)
{
$this
->
data
=
$data
;
}
public
function
getData
()
{
return
$this
->
data
;
}
}
\ No newline at end of file
tests/Doctrine/Tests/Models/Company/CompanyEvent.php
0 → 100644
View file @
3d3bcc17
<?php
namespace
Doctrine\Tests\Models\Company
;
/**
* @Entity @Table(name="company_events")
* @InheritanceType("JOINED")
* @DiscriminatorColumn(name="event_type", type="string")
* @DiscriminatorMap({"auction" = "CompanyAuction", "raffle" = "CompanyRaffle"})
*/
class
CompanyEvent
{
/**
* @Id @Column(type="integer")
* @GeneratedValue(strategy="AUTO")
*/
private
$id
;
/**
* @OneToOne(targetEntity="CompanyOrganization",cascade={"persist"})
* @JoinColumn(name="org_id", referencedColumnName="id")
*/
private
$organization
;
public
function
getId
()
{
return
$this
->
id
;
}
public
function
getOrganization
()
{
return
$this
->
organization
;
}
public
function
setOrganization
(
CompanyOrganization
$org
)
{
$this
->
organization
=
$org
;
}
}
\ No newline at end of file
tests/Doctrine/Tests/Models/Company/CompanyOrganization.php
0 → 100644
View file @
3d3bcc17
<?php
namespace
Doctrine\Tests\Models\Company
;
/** @Entity @Table(name="company_organizations") */
class
CompanyOrganization
{
/**
* @Id @Column(type="integer")
* @GeneratedValue(strategy="AUTO")
*/
private
$id
;
/**
* @OneToMany(targetEntity="CompanyEvent", mappedBy="organization", cascade={"persist"})
*/
private
$events
;
public
function
getId
()
{
return
$this
->
id
;
}
public
function
getEvents
()
{
return
$this
->
events
;
}
public
function
addEvent
(
CompanyEvent
$event
)
{
$this
->
events
[]
=
$event
;
$event
->
setOrganization
(
$this
);
}
}
\ No newline at end of file
tests/Doctrine/Tests/Models/Company/CompanyRaffle.php
0 → 100644
View file @
3d3bcc17
<?php
namespace
Doctrine\Tests\Models\Company
;
/** @Entity @Table(name="company_raffles") */
class
CompanyRaffle
extends
CompanyEvent
{
/** @Column(type="string") */
private
$data
;
public
function
setData
(
$data
)
{
$this
->
data
=
$data
;
}
public
function
getData
()
{
return
$this
->
data
;
}
}
\ No newline at end of file
tests/Doctrine/Tests/ORM/Functional/ClassTableInheritanceTest.php
View file @
3d3bcc17
...
...
@@ -4,9 +4,13 @@ namespace Doctrine\Tests\ORM\Functional;
require_once
__DIR__
.
'/../../TestInit.php'
;
use
Doctrine\Tests\Models\Company\CompanyPerson
;
use
Doctrine\Tests\Models\Company\CompanyEmployee
;
use
Doctrine\Tests\Models\Company\CompanyManager
;
use
Doctrine\Tests\Models\Company\CompanyPerson
,
Doctrine\Tests\Models\Company\CompanyEmployee
,
Doctrine\Tests\Models\Company\CompanyManager
,
Doctrine\Tests\Models\Company\CompanyOrganization
,
Doctrine\Tests\Models\Company\CompanyEvent
,
Doctrine\Tests\Models\Company\CompanyAuction
,
Doctrine\Tests\Models\Company\CompanyRaffle
;
/**
* Functional tests for the Class Table Inheritance mapping strategy.
...
...
@@ -176,4 +180,46 @@ class ClassTableInheritanceTest extends \Doctrine\Tests\OrmFunctionalTestCase
$friends
=
$result
[
0
]
->
getFriends
();
$this
->
assertEquals
(
'Jonathan'
,
$friends
[
0
]
->
getName
());
}
public
function
testLazyLoading1
()
{
$org
=
new
CompanyOrganization
;
$event1
=
new
CompanyAuction
;
$event1
->
setData
(
'auction'
);
$org
->
addEvent
(
$event1
);
$event2
=
new
CompanyRaffle
;
$event2
->
setData
(
'raffle'
);
$org
->
addEvent
(
$event2
);
$this
->
_em
->
persist
(
$org
);
$this
->
_em
->
flush
();
$this
->
_em
->
clear
();
$orgId
=
$org
->
getId
();
$this
->
_em
->
getConfiguration
()
->
setAllowPartialObjects
(
false
);
$q
=
$this
->
_em
->
createQuery
(
'select a from Doctrine\Tests\Models\Company\CompanyOrganization a where a.id = ?1'
);
$q
->
setParameter
(
1
,
$orgId
);
$result
=
$q
->
getResult
();
$this
->
assertEquals
(
1
,
count
(
$result
));
$this
->
assertTrue
(
$result
[
0
]
instanceof
CompanyOrganization
);
$events
=
$result
[
0
]
->
getEvents
();
$this
->
assertTrue
(
$events
instanceof
\Doctrine\ORM\PersistentCollection
);
$this
->
assertFalse
(
$events
->
isInitialized
());
$this
->
assertEquals
(
2
,
count
(
$events
));
if
(
$events
[
0
]
instanceof
CompanyAuction
)
{
$this
->
assertTrue
(
$events
[
1
]
instanceof
CompanyRaffle
);
}
else
{
$this
->
assertTrue
(
$events
[
0
]
instanceof
CompanyRaffle
);
$this
->
assertTrue
(
$events
[
1
]
instanceof
CompanyAuction
);
}
$this
->
_em
->
getConfiguration
()
->
setAllowPartialObjects
(
true
);
}
}
tests/Doctrine/Tests/OrmFunctionalTestCase.php
View file @
3d3bcc17
...
...
@@ -42,7 +42,11 @@ class OrmFunctionalTestCase extends OrmTestCase
'company'
=>
array
(
'Doctrine\Tests\Models\Company\CompanyPerson'
,
'Doctrine\Tests\Models\Company\CompanyEmployee'
,
'Doctrine\Tests\Models\Company\CompanyManager'
'Doctrine\Tests\Models\Company\CompanyManager'
,
'Doctrine\Tests\Models\Company\CompanyOrganization'
,
'Doctrine\Tests\Models\Company\CompanyEvent'
,
'Doctrine\Tests\Models\Company\CompanyAuction'
,
'Doctrine\Tests\Models\Company\CompanyRaffle'
),
'ecommerce'
=>
array
(
'Doctrine\Tests\Models\ECommerce\ECommerceCart'
,
...
...
@@ -94,6 +98,10 @@ class OrmFunctionalTestCase extends OrmTestCase
$conn
->
executeUpdate
(
'DELETE FROM company_employees'
);
$conn
->
executeUpdate
(
'UPDATE company_persons SET spouse_id = NULL'
);
$conn
->
executeUpdate
(
'DELETE FROM company_persons'
);
$conn
->
executeUpdate
(
'DELETE FROM company_raffles'
);
$conn
->
executeUpdate
(
'DELETE FROM company_auctions'
);
$conn
->
executeUpdate
(
'DELETE FROM company_events'
);
$conn
->
executeUpdate
(
'DELETE FROM company_organizations'
);
}
if
(
isset
(
$this
->
_usedModelSets
[
'generic'
]))
{
$conn
->
executeUpdate
(
'DELETE FROM date_time_model'
);
...
...
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