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
db603547
Commit
db603547
authored
Apr 13, 2010
by
Roman S. Borschel
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Added failing test for DDC-388. Naming refactorings and comment cleanups.
parent
cb616956
Changes
10
Hide whitespace changes
Inline
Side-by-side
Showing
10 changed files
with
78 additions
and
87 deletions
+78
-87
Configuration.php
lib/Doctrine/ORM/Configuration.php
+0
-2
ClassMetadata.php
lib/Doctrine/ORM/Mapping/ClassMetadata.php
+5
-5
NativeQuery.php
lib/Doctrine/ORM/NativeQuery.php
+0
-4
OptimisticLockException.php
lib/Doctrine/ORM/OptimisticLockException.php
+2
-5
AbstractCollectionPersister.php
lib/Doctrine/ORM/Persisters/AbstractCollectionPersister.php
+15
-19
AbstractEntityInheritancePersister.php
...ine/ORM/Persisters/AbstractEntityInheritancePersister.php
+0
-2
Query.php
lib/Doctrine/ORM/Query.php
+11
-15
SqlWalker.php
lib/Doctrine/ORM/Query/SqlWalker.php
+2
-1
QueryBuilder.php
lib/Doctrine/ORM/QueryBuilder.php
+29
-34
BasicInheritanceMappingTest.php
...octrine/Tests/ORM/Mapping/BasicInheritanceMappingTest.php
+14
-0
No files found.
lib/Doctrine/ORM/Configuration.php
View file @
db603547
<?php
/*
* $Id$
*
* 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
...
...
lib/Doctrine/ORM/Mapping/ClassMetadata.php
View file @
db603547
...
...
@@ -339,11 +339,11 @@ class ClassMetadata extends ClassMetadataInfo
$this
->
reflClass
=
new
ReflectionClass
(
$this
->
name
);
foreach
(
$this
->
fieldMappings
as
$field
=>
$mapping
)
{
if
(
isset
(
$mapping
[
'inherited'
]))
{
$reflField
=
new
ReflectionProperty
(
$mapping
[
'inherited'
],
$field
);
}
else
{
$reflField
=
$this
->
reflClass
->
getProperty
(
$field
);
}
if
(
isset
(
$mapping
[
'inherited'
]))
{
$reflField
=
new
ReflectionProperty
(
$mapping
[
'inherited'
],
$field
);
}
else
{
$reflField
=
$this
->
reflClass
->
getProperty
(
$field
);
}
$reflField
->
setAccessible
(
true
);
$this
->
reflFields
[
$field
]
=
$reflField
;
}
...
...
lib/Doctrine/ORM/NativeQuery.php
View file @
db603547
<?php
/*
* $Id$
*
* 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
...
...
@@ -21,8 +19,6 @@
namespace
Doctrine\ORM
;
use
Doctrine\DBAL\Types\Type
;
/**
* Represents a native SQL query.
*
...
...
lib/Doctrine/ORM/OptimisticLockException.php
View file @
db603547
...
...
@@ -24,11 +24,8 @@ namespace Doctrine\ORM;
/**
* OptimisticLockException
*
* @author Roman Borschel <roman@code-factory.org>
* @license http://www.opensource.org/licenses/lgpl-license.php LGPL
* @link www.doctrine-project.org
* @since 2.0
* @version $Revision$
* @author Roman Borschel <roman@code-factory.org>
* @since 2.0
*/
class
OptimisticLockException
extends
ORMException
{
...
...
lib/Doctrine/ORM/Persisters/AbstractCollectionPersister.php
View file @
db603547
<?php
/*
* $Id$
*
* 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
...
...
@@ -33,19 +31,17 @@ use Doctrine\ORM\EntityManager,
abstract
class
AbstractCollectionPersister
{
/**
*
* @var EntityManager
*/
protected
$_em
;
/**
* @var
\
Doctrine\DBAL\Connection
* @var Doctrine\DBAL\Connection
*/
protected
$_conn
;
/**
*
* @var \Doctrine\ORM\UnitOfWork
* @var Doctrine\ORM\UnitOfWork
*/
protected
$_uow
;
...
...
@@ -71,8 +67,8 @@ abstract class AbstractCollectionPersister
if
(
!
$coll
->
getMapping
()
->
isOwningSide
)
{
return
;
// ignore inverse side
}
$sql
=
$this
->
_getDeleteS
ql
(
$coll
);
$this
->
_conn
->
executeUpdate
(
$sql
,
$this
->
_getDeleteS
ql
Parameters
(
$coll
));
$sql
=
$this
->
_getDeleteS
QL
(
$coll
);
$this
->
_conn
->
executeUpdate
(
$sql
,
$this
->
_getDeleteS
QL
Parameters
(
$coll
));
}
/**
...
...
@@ -80,7 +76,7 @@ abstract class AbstractCollectionPersister
*
* @param PersistentCollection $coll
*/
abstract
protected
function
_getDeleteS
ql
(
PersistentCollection
$coll
);
abstract
protected
function
_getDeleteS
QL
(
PersistentCollection
$coll
);
/**
* Gets the SQL parameters for the corresponding SQL statement to delete
...
...
@@ -88,7 +84,7 @@ abstract class AbstractCollectionPersister
*
* @param PersistentCollection $coll
*/
abstract
protected
function
_getDeleteS
ql
Parameters
(
PersistentCollection
$coll
);
abstract
protected
function
_getDeleteS
QL
Parameters
(
PersistentCollection
$coll
);
/**
* Updates the given collection, synchronizing it's state with the database
...
...
@@ -109,9 +105,9 @@ abstract class AbstractCollectionPersister
public
function
deleteRows
(
PersistentCollection
$coll
)
{
$deleteDiff
=
$coll
->
getDeleteDiff
();
$sql
=
$this
->
_getDeleteRowS
ql
(
$coll
);
$sql
=
$this
->
_getDeleteRowS
QL
(
$coll
);
foreach
(
$deleteDiff
as
$element
)
{
$this
->
_conn
->
executeUpdate
(
$sql
,
$this
->
_getDeleteRowS
ql
Parameters
(
$coll
,
$element
));
$this
->
_conn
->
executeUpdate
(
$sql
,
$this
->
_getDeleteRowS
QL
Parameters
(
$coll
,
$element
));
}
}
...
...
@@ -121,9 +117,9 @@ abstract class AbstractCollectionPersister
public
function
insertRows
(
PersistentCollection
$coll
)
{
$insertDiff
=
$coll
->
getInsertDiff
();
$sql
=
$this
->
_getInsertRowS
ql
(
$coll
);
$sql
=
$this
->
_getInsertRowS
QL
(
$coll
);
foreach
(
$insertDiff
as
$element
)
{
$this
->
_conn
->
executeUpdate
(
$sql
,
$this
->
_getInsertRowS
ql
Parameters
(
$coll
,
$element
));
$this
->
_conn
->
executeUpdate
(
$sql
,
$this
->
_getInsertRowS
QL
Parameters
(
$coll
,
$element
));
}
}
...
...
@@ -132,7 +128,7 @@ abstract class AbstractCollectionPersister
*
* @param PersistentCollection $coll
*/
abstract
protected
function
_getDeleteRowS
ql
(
PersistentCollection
$coll
);
abstract
protected
function
_getDeleteRowS
QL
(
PersistentCollection
$coll
);
/**
* Gets the SQL parameters for the corresponding SQL statement to delete the given
...
...
@@ -141,21 +137,21 @@ abstract class AbstractCollectionPersister
* @param PersistentCollection $coll
* @param mixed $element
*/
abstract
protected
function
_getDeleteRowS
ql
Parameters
(
PersistentCollection
$coll
,
$element
);
abstract
protected
function
_getDeleteRowS
QL
Parameters
(
PersistentCollection
$coll
,
$element
);
/**
* Gets the SQL statement used for updating a row in the collection.
*
* @param PersistentCollection $coll
*/
abstract
protected
function
_getUpdateRowS
ql
(
PersistentCollection
$coll
);
abstract
protected
function
_getUpdateRowS
QL
(
PersistentCollection
$coll
);
/**
* Gets the SQL statement used for inserting a row in the collection.
*
* @param PersistentCollection $coll
*/
abstract
protected
function
_getInsertRowS
ql
(
PersistentCollection
$coll
);
abstract
protected
function
_getInsertRowS
QL
(
PersistentCollection
$coll
);
/**
* Gets the SQL parameters for the corresponding SQL statement to insert the given
...
...
@@ -164,5 +160,5 @@ abstract class AbstractCollectionPersister
* @param PersistentCollection $coll
* @param mixed $element
*/
abstract
protected
function
_getInsertRowS
ql
Parameters
(
PersistentCollection
$coll
,
$element
);
abstract
protected
function
_getInsertRowS
QL
Parameters
(
PersistentCollection
$coll
,
$element
);
}
\ No newline at end of file
lib/Doctrine/ORM/Persisters/AbstractEntityInheritancePersister.php
View file @
db603547
<?php
/*
* $Id$
*
* 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
...
...
lib/Doctrine/ORM/Query.php
View file @
db603547
<?php
/*
* $Id$
*
* 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
...
...
@@ -27,13 +25,10 @@ use Doctrine\ORM\Query\Parser,
/**
* A Query object represents a DQL query.
*
* @license http://www.opensource.org/licenses/lgpl-license.php LGPL
* @link www.doctrine-project.org
* @since 1.0
* @version $Revision: 3938 $
* @author Guilherme Blanco <guilhermeblanco@hotmail.com>
* @author Konsta Vesterinen <kvesteri@cc.hut.fi>
* @author Roman Borschel <roman@code-factory.org>
* @since 1.0
* @author Guilherme Blanco <guilhermeblanco@hotmail.com>
* @author Konsta Vesterinen <kvesteri@cc.hut.fi>
* @author Roman Borschel <roman@code-factory.org>
*/
final
class
Query
extends
AbstractQuery
{
...
...
@@ -62,6 +57,7 @@ final class Query extends AbstractQuery
* partial objects.
*
* @var string
* @todo Rename: HINT_OPTIMIZE
*/
const
HINT_FORCE_PARTIAL_LOAD
=
'doctrine.forcePartialLoad'
;
/**
...
...
@@ -149,10 +145,10 @@ final class Query extends AbstractQuery
*
* @param Doctrine\ORM\EntityManager $entityManager
*/
public
function
__construct
(
EntityManager
$entityManager
)
/*
public function __construct(EntityManager $entityManager)
{
parent::__construct($entityManager);
}
}
*/
/**
* Gets the SQL query/queries that correspond to this DQL query.
...
...
@@ -162,7 +158,7 @@ final class Query extends AbstractQuery
*/
public
function
getSQL
()
{
return
$this
->
_parse
()
->
getS
qlExecutor
()
->
getSql
Statements
();
return
$this
->
_parse
()
->
getS
QLExecutor
()
->
getSQL
Statements
();
}
/**
...
...
@@ -366,7 +362,7 @@ final class Query extends AbstractQuery
* @param string $dqlQuery DQL Query
* @return Doctrine\ORM\AbstractQuery
*/
public
function
setD
ql
(
$dqlQuery
)
public
function
setD
QL
(
$dqlQuery
)
{
if
(
$dqlQuery
!==
null
)
{
$this
->
_dql
=
$dqlQuery
;
...
...
@@ -380,7 +376,7 @@ final class Query extends AbstractQuery
*
* @return string DQL query
*/
public
function
getD
ql
()
public
function
getD
QL
()
{
return
$this
->
_dql
;
}
...
...
@@ -408,7 +404,7 @@ final class Query extends AbstractQuery
*/
public
function
contains
(
$dql
)
{
return
stripos
(
$this
->
getD
ql
(),
$dql
)
===
false
?
false
:
true
;
return
stripos
(
$this
->
getD
QL
(),
$dql
)
===
false
?
false
:
true
;
}
/**
...
...
lib/Doctrine/ORM/Query/SqlWalker.php
View file @
db603547
...
...
@@ -432,7 +432,7 @@ class SqlWalker implements TreeWalker
$class
=
$this
->
_em
->
getClassMetadata
(
$class
->
fieldMappings
[
$fieldName
][
'inherited'
]);
}
return
$this
->
getS
ql
TableAlias
(
$class
->
table
[
'name'
],
$identificationVariable
);
return
$this
->
getS
QL
TableAlias
(
$class
->
table
[
'name'
],
$identificationVariable
);
}
/**
...
...
@@ -789,6 +789,7 @@ class SqlWalker implements TreeWalker
$sql
.=
' AND '
.
$discrSql
;
}
//FIXME: these should either be nested or all forced to be left joins (DDC-XXX)
if
(
$targetClass
->
isInheritanceTypeJoined
())
{
$sql
.=
$this
->
_generateClassTableInheritanceJoins
(
$targetClass
,
$joinedDqlAlias
);
}
...
...
lib/Doctrine/ORM/QueryBuilder.php
View file @
db603547
...
...
@@ -168,7 +168,7 @@ class QueryBuilder
*
* @return string The DQL string
*/
public
function
getD
ql
()
public
function
getD
QL
()
{
if
(
$this
->
_dql
!==
null
&&
$this
->
_state
===
self
::
STATE_CLEAN
)
{
return
$this
->
_dql
;
...
...
@@ -178,16 +178,16 @@ class QueryBuilder
switch
(
$this
->
_type
)
{
case
self
::
DELETE
:
$dql
=
$this
->
_getD
ql
ForDelete
();
$dql
=
$this
->
_getD
QL
ForDelete
();
break
;
case
self
::
UPDATE
:
$dql
=
$this
->
_getD
ql
ForUpdate
();
$dql
=
$this
->
_getD
QL
ForUpdate
();
break
;
case
self
::
SELECT
:
default
:
$dql
=
$this
->
_getD
ql
ForSelect
();
$dql
=
$this
->
_getD
QL
ForSelect
();
break
;
}
...
...
@@ -211,7 +211,7 @@ class QueryBuilder
*/
public
function
getQuery
()
{
return
$this
->
_em
->
createQuery
(
$this
->
getD
ql
())
return
$this
->
_em
->
createQuery
(
$this
->
getD
QL
())
->
setParameters
(
$this
->
_params
)
->
setFirstResult
(
$this
->
_firstResult
)
->
setMaxResults
(
$this
->
_maxResults
);
...
...
@@ -613,7 +613,7 @@ class QueryBuilder
*/
public
function
andWhere
(
$where
)
{
$where
=
$this
->
getD
ql
Part
(
'where'
);
$where
=
$this
->
getD
QL
Part
(
'where'
);
$args
=
func_get_args
();
if
(
$where
instanceof
Expr\Andx
)
{
...
...
@@ -744,7 +744,7 @@ class QueryBuilder
array_unshift
(
$args
,
$having
);
$having
=
new
Expr\Orx
(
$args
);
}
return
$this
->
add
(
'having'
,
$having
);
}
...
...
@@ -779,7 +779,7 @@ class QueryBuilder
* @param string $queryPartName
* @return mixed $queryPart
*/
public
function
getD
ql
Part
(
$queryPartName
)
public
function
getD
QL
Part
(
$queryPartName
)
{
return
$this
->
_dqlParts
[
$queryPartName
];
}
...
...
@@ -789,43 +789,43 @@ class QueryBuilder
*
* @return array $dqlParts
*/
public
function
getD
ql
Parts
()
public
function
getD
QL
Parts
()
{
return
$this
->
_dqlParts
;
}
private
function
_getD
ql
ForDelete
()
private
function
_getD
QL
ForDelete
()
{
return
'DELETE'
.
$this
->
_getReducedD
ql
QueryPart
(
'from'
,
array
(
'pre'
=>
' '
,
'separator'
=>
', '
))
.
$this
->
_getReducedD
ql
QueryPart
(
'where'
,
array
(
'pre'
=>
' WHERE '
))
.
$this
->
_getReducedD
ql
QueryPart
(
'orderBy'
,
array
(
'pre'
=>
' ORDER BY '
,
'separator'
=>
', '
));
.
$this
->
_getReducedD
QL
QueryPart
(
'from'
,
array
(
'pre'
=>
' '
,
'separator'
=>
', '
))
.
$this
->
_getReducedD
QL
QueryPart
(
'where'
,
array
(
'pre'
=>
' WHERE '
))
.
$this
->
_getReducedD
QL
QueryPart
(
'orderBy'
,
array
(
'pre'
=>
' ORDER BY '
,
'separator'
=>
', '
));
}
private
function
_getD
ql
ForUpdate
()
private
function
_getD
QL
ForUpdate
()
{
return
'UPDATE'
.
$this
->
_getReducedD
ql
QueryPart
(
'from'
,
array
(
'pre'
=>
' '
,
'separator'
=>
', '
))
.
$this
->
_getReducedD
ql
QueryPart
(
'set'
,
array
(
'pre'
=>
' SET '
,
'separator'
=>
', '
))
.
$this
->
_getReducedD
ql
QueryPart
(
'where'
,
array
(
'pre'
=>
' WHERE '
))
.
$this
->
_getReducedD
ql
QueryPart
(
'orderBy'
,
array
(
'pre'
=>
' ORDER BY '
,
'separator'
=>
', '
));
.
$this
->
_getReducedD
QL
QueryPart
(
'from'
,
array
(
'pre'
=>
' '
,
'separator'
=>
', '
))
.
$this
->
_getReducedD
QL
QueryPart
(
'set'
,
array
(
'pre'
=>
' SET '
,
'separator'
=>
', '
))
.
$this
->
_getReducedD
QL
QueryPart
(
'where'
,
array
(
'pre'
=>
' WHERE '
))
.
$this
->
_getReducedD
QL
QueryPart
(
'orderBy'
,
array
(
'pre'
=>
' ORDER BY '
,
'separator'
=>
', '
));
}
private
function
_getD
ql
ForSelect
()
private
function
_getD
QL
ForSelect
()
{
return
'SELECT'
.
$this
->
_getReducedD
ql
QueryPart
(
'select'
,
array
(
'pre'
=>
' '
,
'separator'
=>
', '
))
.
$this
->
_getReducedD
ql
QueryPart
(
'from'
,
array
(
'pre'
=>
' FROM '
,
'separator'
=>
', '
))
.
$this
->
_getReducedD
ql
QueryPart
(
'join'
,
array
(
'pre'
=>
' '
,
'separator'
=>
' '
))
.
$this
->
_getReducedD
ql
QueryPart
(
'where'
,
array
(
'pre'
=>
' WHERE '
))
.
$this
->
_getReducedD
ql
QueryPart
(
'groupBy'
,
array
(
'pre'
=>
' GROUP BY '
,
'separator'
=>
', '
))
.
$this
->
_getReducedD
ql
QueryPart
(
'having'
,
array
(
'pre'
=>
' HAVING '
))
.
$this
->
_getReducedD
ql
QueryPart
(
'orderBy'
,
array
(
'pre'
=>
' ORDER BY '
,
'separator'
=>
', '
));
.
$this
->
_getReducedD
QL
QueryPart
(
'select'
,
array
(
'pre'
=>
' '
,
'separator'
=>
', '
))
.
$this
->
_getReducedD
QL
QueryPart
(
'from'
,
array
(
'pre'
=>
' FROM '
,
'separator'
=>
', '
))
.
$this
->
_getReducedD
QL
QueryPart
(
'join'
,
array
(
'pre'
=>
' '
,
'separator'
=>
' '
))
.
$this
->
_getReducedD
QL
QueryPart
(
'where'
,
array
(
'pre'
=>
' WHERE '
))
.
$this
->
_getReducedD
QL
QueryPart
(
'groupBy'
,
array
(
'pre'
=>
' GROUP BY '
,
'separator'
=>
', '
))
.
$this
->
_getReducedD
QL
QueryPart
(
'having'
,
array
(
'pre'
=>
' HAVING '
))
.
$this
->
_getReducedD
QL
QueryPart
(
'orderBy'
,
array
(
'pre'
=>
' ORDER BY '
,
'separator'
=>
', '
));
}
private
function
_getReducedD
ql
QueryPart
(
$queryPartName
,
$options
=
array
())
private
function
_getReducedD
QL
QueryPart
(
$queryPartName
,
$options
=
array
())
{
$queryPart
=
$this
->
getD
ql
Part
(
$queryPartName
);
$queryPart
=
$this
->
getD
QL
Part
(
$queryPartName
);
if
(
empty
(
$queryPart
))
{
return
(
isset
(
$options
[
'empty'
])
?
$options
[
'empty'
]
:
''
);
...
...
@@ -838,11 +838,6 @@ class QueryBuilder
public
function
__toString
()
{
return
$this
->
getD
ql
();
return
$this
->
getD
QL
();
}
/*public function __clone()
{
$this->_q = clone $this->_q;
}*/
}
\ No newline at end of file
tests/Doctrine/Tests/ORM/Mapping/BasicInheritanceMappingTest.php
View file @
db603547
...
...
@@ -51,6 +51,20 @@ class BasicInheritanceMappingTest extends \Doctrine\Tests\OrmTestCase
$this
->
assertTrue
(
empty
(
$class
->
inheritedAssociationFields
));
$this
->
assertTrue
(
isset
(
$class
->
associationMappings
[
'mappedRelated1'
]));
}
/**
* @group DDC-388
*/
public
function
testSerializationWithPrivateFieldsFromMappedSuperclass
()
{
$class
=
$this
->
_factory
->
getMetadataFor
(
__NAMESPACE__
.
'\\EntitySubClass2'
);
$class2
=
unserialize
(
serialize
(
$class
));
$this
->
assertTrue
(
isset
(
$class2
->
reflFields
[
'mapped1'
]));
$this
->
assertTrue
(
isset
(
$class2
->
reflFields
[
'mapped2'
]));
}
}
class
TransientBaseClass
{
...
...
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