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
435acc91
Commit
435acc91
authored
Oct 01, 2009
by
romanb
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[2.0][DDC-24] Fixed (together with some small misc. refactorings).
parent
8f2d59c2
Changes
18
Hide whitespace changes
Inline
Side-by-side
Showing
18 changed files
with
82 additions
and
27 deletions
+82
-27
AbstractPlatform.php
lib/Doctrine/DBAL/Platforms/AbstractPlatform.php
+7
-0
MsSqlPlatform.php
lib/Doctrine/DBAL/Platforms/MsSqlPlatform.php
+6
-0
MySqlPlatform.php
lib/Doctrine/DBAL/Platforms/MySqlPlatform.php
+2
-1
OraclePlatform.php
lib/Doctrine/DBAL/Platforms/OraclePlatform.php
+6
-0
PostgreSqlPlatform.php
lib/Doctrine/DBAL/Platforms/PostgreSqlPlatform.php
+6
-0
SqlitePlatform.php
lib/Doctrine/DBAL/Platforms/SqlitePlatform.php
+5
-0
PostgreSqlSchemaManager.php
lib/Doctrine/DBAL/Schema/PostgreSqlSchemaManager.php
+4
-1
SqliteSchemaManager.php
lib/Doctrine/DBAL/Schema/SqliteSchemaManager.php
+3
-0
ObjectType.php
lib/Doctrine/DBAL/Types/ObjectType.php
+1
-1
TextType.php
lib/Doctrine/DBAL/Types/TextType.php
+1
-1
EntityRepository.php
lib/Doctrine/ORM/EntityRepository.php
+1
-1
ObjectHydrator.php
lib/Doctrine/ORM/Internal/Hydration/ObjectHydrator.php
+2
-2
ProxyClassGenerator.php
lib/Doctrine/ORM/Proxy/ProxyClassGenerator.php
+11
-3
UnitOfWork.php
lib/Doctrine/ORM/UnitOfWork.php
+4
-17
MockPlatform.php
tests/Doctrine/Tests/DBAL/Mocks/MockPlatform.php
+6
-0
DatabasePlatformMock.php
tests/Doctrine/Tests/Mocks/DatabasePlatformMock.php
+3
-0
CmsAddress.php
tests/Doctrine/Tests/Models/CMS/CmsAddress.php
+7
-0
CmsUser.php
tests/Doctrine/Tests/Models/CMS/CmsUser.php
+7
-0
No files found.
lib/Doctrine/DBAL/Platforms/AbstractPlatform.php
View file @
435acc91
...
...
@@ -1551,6 +1551,13 @@ abstract class AbstractPlatform
* @param array $field
*/
abstract
public
function
getVarcharTypeDeclarationSql
(
array
$field
);
/**
* Gets the SQL snippet used to declare a CLOB column type.
*
* @param array $field
*/
abstract
public
function
getClobTypeDeclarationSql
(
array
$field
);
/**
* Gets the name of the platform.
...
...
lib/Doctrine/DBAL/Platforms/MsSqlPlatform.php
View file @
435acc91
...
...
@@ -365,6 +365,12 @@ class MsSqlPlatform extends AbstractPlatform
return
$fixed
?
(
$length
?
'CHAR('
.
$length
.
')'
:
'CHAR(255)'
)
:
(
$length
?
'VARCHAR('
.
$length
.
')'
:
'TEXT'
);
}
/** @override */
public
function
getClobTypeDeclarationSql
(
array
$field
)
{
return
'TEXT'
;
}
/**
* @override
...
...
lib/Doctrine/DBAL/Platforms/MySqlPlatform.php
View file @
435acc91
...
...
@@ -231,7 +231,8 @@ class MySqlPlatform extends AbstractPlatform
:
(
$length
?
'VARCHAR('
.
$length
.
')'
:
'VARCHAR(255)'
);
}
public
function
getClobDeclarationSql
(
array
$field
)
/** @override */
public
function
getClobTypeDeclarationSql
(
array
$field
)
{
if
(
!
empty
(
$field
[
'length'
]))
{
$length
=
$field
[
'length'
];
...
...
lib/Doctrine/DBAL/Platforms/OraclePlatform.php
View file @
435acc91
...
...
@@ -223,6 +223,12 @@ class OraclePlatform extends AbstractPlatform
return
$fixed
?
(
$length
?
'CHAR('
.
$length
.
')'
:
'CHAR(2000)'
)
:
(
$length
?
'VARCHAR2('
.
$length
.
')'
:
'VARCHAR2(4000)'
);
}
/** @override */
public
function
getClobTypeDeclarationSql
(
array
$field
)
{
return
'CLOB'
;
}
public
function
getListDatabasesSql
()
{
...
...
lib/Doctrine/DBAL/Platforms/PostgreSqlPlatform.php
View file @
435acc91
...
...
@@ -742,6 +742,12 @@ class PostgreSqlPlatform extends AbstractPlatform
return
$fixed
?
(
$length
?
'CHAR('
.
$length
.
')'
:
'CHAR(255)'
)
:
(
$length
?
'VARCHAR('
.
$length
.
')'
:
'TEXT'
);
}
/** @override */
public
function
getClobTypeDeclarationSql
(
array
$field
)
{
return
'TEXT'
;
}
/**
* Get the platform name for this instance
...
...
lib/Doctrine/DBAL/Platforms/SqlitePlatform.php
View file @
435acc91
...
...
@@ -370,6 +370,11 @@ class SqlitePlatform extends AbstractPlatform
return
$fixed
?
(
$length
?
'CHAR('
.
$length
.
')'
:
'CHAR(255)'
)
:
(
$length
?
'VARCHAR('
.
$length
.
')'
:
'TEXT'
);
}
public
function
getClobTypeDeclarationSql
(
array
$field
)
{
return
'CLOB'
;
}
public
function
getListSequencesSql
(
$database
)
{
...
...
lib/Doctrine/DBAL/Schema/PostgreSqlSchemaManager.php
View file @
435acc91
...
...
@@ -172,6 +172,9 @@ class PostgreSqlSchemaManager extends AbstractSchemaManager
$length
=
1
;
break
;
case
'text'
:
$fixed
=
false
;
$type
=
'text'
;
break
;
case
'varchar'
:
case
'interval'
:
case
'_varchar'
:
...
...
@@ -186,7 +189,7 @@ class PostgreSqlSchemaManager extends AbstractSchemaManager
$type
=
'boolean'
;
}
}
elseif
(
strstr
(
$dbType
,
'text'
))
{
$type
=
'
clob
'
;
$type
=
'
text
'
;
}
if
(
$fixed
!==
false
)
{
$fixed
=
true
;
...
...
lib/Doctrine/DBAL/Schema/SqliteSchemaManager.php
View file @
435acc91
...
...
@@ -138,6 +138,9 @@ class SqliteSchemaManager extends AbstractSchemaManager
$length
=
8
;
break
;
case
'clob'
:
$fixed
=
false
;
$type
=
'text'
;
break
;
case
'tinytext'
:
case
'mediumtext'
:
case
'longtext'
:
...
...
lib/Doctrine/DBAL/Types/ObjectType.php
View file @
435acc91
...
...
@@ -11,7 +11,7 @@ class ObjectType extends Type
{
public
function
getSqlDeclaration
(
array
$fieldDeclaration
,
\Doctrine\DBAL\Platforms\AbstractPlatform
$platform
)
{
return
$platform
->
getClobDeclarationSql
(
$fieldDeclaration
);
return
$platform
->
getClob
Type
DeclarationSql
(
$fieldDeclaration
);
}
public
function
convertToDatabaseValue
(
$value
,
\Doctrine\DBAL\Platforms\AbstractPlatform
$platform
)
...
...
lib/Doctrine/DBAL/Types/TextType.php
View file @
435acc91
...
...
@@ -12,7 +12,7 @@ class TextType extends Type
/** @override */
public
function
getSqlDeclaration
(
array
$fieldDeclaration
,
\Doctrine\DBAL\Platforms\AbstractPlatform
$platform
)
{
return
$platform
->
getClobDeclarationSql
(
$fieldDeclaration
);
return
$platform
->
getClob
Type
DeclarationSql
(
$fieldDeclaration
);
}
public
function
getName
()
...
...
lib/Doctrine/ORM/EntityRepository.php
View file @
435acc91
...
...
@@ -134,7 +134,7 @@ class EntityRepository
$by
=
substr
(
$method
,
9
,
strlen
(
$method
));
$method
=
'findOneBy'
;
}
else
{
throw
new
BadMethodCallException
(
"Undefined method '
$method
'."
);
throw
new
\
BadMethodCallException
(
"Undefined method '
$method
'."
);
}
if
(
!
isset
(
$arguments
[
0
]))
{
...
...
lib/Doctrine/ORM/Internal/Hydration/ObjectHydrator.php
View file @
435acc91
...
...
@@ -340,7 +340,7 @@ class ObjectHydrator extends AbstractHydrator
}
else
{
// Single-valued association
$reflFieldValue
=
$reflField
->
getValue
(
$baseElement
);
if
(
!
$reflFieldValue
)
{
if
(
!
$reflFieldValue
/* || doctrine.refresh hint set */
)
{
if
(
isset
(
$nonemptyComponents
[
$dqlAlias
]))
{
$element
=
$this
->
_getEntity
(
$data
,
$dqlAlias
);
$reflField
->
setValue
(
$baseElement
,
$element
);
...
...
@@ -350,7 +350,7 @@ class ObjectHydrator extends AbstractHydrator
// If there is an inverse mapping on the target class its bidirectional
if
(
isset
(
$targetClass
->
inverseMappings
[
$relation
->
sourceEntityName
][
$relationField
]))
{
$sourceProp
=
$targetClass
->
inverseMappings
[
$relation
->
sourceEntityName
][
$relationField
]
->
sourceFieldName
;
$targetClass
->
reflFields
[
$sourceProp
]
->
setValue
(
$element
,
$base
);
$targetClass
->
reflFields
[
$sourceProp
]
->
setValue
(
$element
,
$base
Element
);
}
else
if
(
$this
->
_ce
[
$parentClass
]
===
$targetClass
&&
$relation
->
mappedByFieldName
)
{
// Special case: bi-directional self-referencing one-one on the same class
$targetClass
->
reflFields
[
$relationField
]
->
setValue
(
$element
,
$baseElement
);
...
...
lib/Doctrine/ORM/Proxy/ProxyClassGenerator.php
View file @
435acc91
...
...
@@ -109,19 +109,25 @@ class ProxyClassGenerator
$methods
=
$this
->
_generateMethods
(
$class
);
$sleepImpl
=
$this
->
_generateSleep
(
$class
);
$constructorInv
=
$class
->
reflClass
->
hasMethod
(
'__construct'
)
?
'parent::__construct();'
:
''
;
$placeholders
=
array
(
'<proxyClassName>'
,
'<className>'
,
'<methods>'
,
'<sleepImpl>'
'<methods>'
,
'<sleepImpl>'
,
'<constructorInvocation>'
);
$replacements
=
array
(
$proxyClassName
,
$originalClassName
,
$methods
,
$sleepImpl
$proxyClassName
,
$originalClassName
,
$methods
,
$sleepImpl
,
$constructorInv
);
$file
=
str_replace
(
$placeholders
,
$replacements
,
$file
);
file_put_contents
(
$fileName
,
$file
);
require
$fileName
;
return
$proxyFullyQualifiedClassName
;
}
...
...
@@ -130,7 +136,7 @@ class ProxyClassGenerator
$methods
=
''
;
foreach
(
$class
->
reflClass
->
getMethods
()
as
$method
)
{
if
(
$method
->
getName
()
==
'__construct'
)
{
if
(
$method
->
isConstructor
()
)
{
continue
;
}
...
...
@@ -205,6 +211,7 @@ namespace Doctrine\Generated\Proxies {
public function __construct($entityPersister, $identifier) {
$this->_entityPersister = $entityPersister;
$this->_identifier = $identifier;
<constructorInvocation>
}
private function _load() {
if ( ! $this->_loaded) {
...
...
@@ -241,6 +248,7 @@ namespace Doctrine\Generated\Proxies {
$this->_assoc = $assoc;
$this->_owner = $owner;
$this->_joinColumnValues = $joinColumnValues;
<constructorInvocation>
}
private function _load() {
if ( ! $this->_loaded) {
...
...
lib/Doctrine/ORM/UnitOfWork.php
View file @
435acc91
...
...
@@ -1427,6 +1427,7 @@ class UnitOfWork implements PropertyChangedListener
array_combine
(
$class
->
identifier
,
$this
->
_entityIdentifiers
[
$oid
]),
$entity
);
//TODO: refresh (initialized) associations
break
;
default
:
throw
new
\InvalidArgumentException
(
"Entity is not MANAGED."
);
...
...
@@ -1656,7 +1657,7 @@ class UnitOfWork implements PropertyChangedListener
if
(
isset
(
$this
->
_identityMap
[
$class
->
rootEntityName
][
$idHash
]))
{
$entity
=
$this
->
_identityMap
[
$class
->
rootEntityName
][
$idHash
];
$oid
=
spl_object_hash
(
$entity
);
$overrideLocal
Chang
es
=
isset
(
$hints
[
Query
::
HINT_REFRESH
]);
$overrideLocal
Valu
es
=
isset
(
$hints
[
Query
::
HINT_REFRESH
]);
}
else
{
$entity
=
new
$className
;
$oid
=
spl_object_hash
(
$entity
);
...
...
@@ -1667,10 +1668,10 @@ class UnitOfWork implements PropertyChangedListener
if
(
$entity
instanceof
\Doctrine\Common\NotifyPropertyChanged
)
{
$entity
->
addPropertyChangedListener
(
$this
);
}
$overrideLocal
Chang
es
=
true
;
$overrideLocal
Valu
es
=
true
;
}
if
(
$overrideLocal
Chang
es
)
{
if
(
$overrideLocal
Valu
es
)
{
if
(
$this
->
_useCExtension
)
{
doctrine_populate_data
(
$entity
,
$data
);
}
else
{
...
...
@@ -1680,20 +1681,6 @@ class UnitOfWork implements PropertyChangedListener
}
}
}
}
else
{
foreach
(
$data
as
$field
=>
$value
)
{
if
(
isset
(
$class
->
reflFields
[
$field
]))
{
$currentValue
=
$class
->
reflFields
[
$field
]
->
getValue
(
$entity
);
// Only override the current value if:
// a) There was no original value yet (nothing in _originalEntityData)
// or
// b) The original value is the same as the current value (it was not changed).
if
(
!
isset
(
$this
->
_originalEntityData
[
$oid
][
$field
])
||
$currentValue
==
$this
->
_originalEntityData
[
$oid
][
$field
])
{
$class
->
reflFields
[
$field
]
->
setValue
(
$entity
,
$value
);
}
}
}
}
if
(
isset
(
$class
->
lifecycleCallbacks
[
Events
::
postLoad
]))
{
...
...
tests/Doctrine/Tests/DBAL/Mocks/MockPlatform.php
View file @
435acc91
...
...
@@ -16,6 +16,12 @@ class MockPlatform extends \Doctrine\DBAL\Platforms\AbstractPlatform
{
return
"DUMMYVARCHAR()"
;
}
/** @override */
public
function
getClobTypeDeclarationSql
(
array
$field
)
{
return
'DUMMYCLOB'
;
}
public
function
getVarcharDefaultLength
()
{
...
...
tests/Doctrine/Tests/Mocks/DatabasePlatformMock.php
View file @
435acc91
...
...
@@ -57,6 +57,9 @@ class DatabasePlatformMock extends \Doctrine\DBAL\Platforms\AbstractPlatform
/** @override */
public
function
getVarcharTypeDeclarationSql
(
array
$field
)
{}
/** @override */
public
function
getClobTypeDeclarationSql
(
array
$field
)
{}
/* MOCK API */
...
...
tests/Doctrine/Tests/Models/CMS/CmsAddress.php
View file @
435acc91
...
...
@@ -54,4 +54,11 @@ class CmsAddress
public
function
getCity
()
{
return
$this
->
city
;
}
public
function
setUser
(
CmsUser
$user
)
{
if
(
$this
->
user
!==
$user
)
{
$this
->
user
=
$user
;
$user
->
setAddress
(
$this
);
}
}
}
\ No newline at end of file
tests/Doctrine/Tests/Models/CMS/CmsUser.php
View file @
435acc91
...
...
@@ -107,4 +107,11 @@ class CmsUser
}
return
false
;
}
public
function
setAddress
(
CmsAddress
$address
)
{
if
(
$this
->
address
!==
$address
)
{
$this
->
address
=
$address
;
$address
->
setUser
(
$this
);
}
}
}
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