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
b6e385d2
Commit
b6e385d2
authored
Jan 08, 2009
by
romanb
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fixed regression
parent
d9733637
Changes
9
Hide whitespace changes
Inline
Side-by-side
Showing
9 changed files
with
47 additions
and
46 deletions
+47
-46
SqlitePlatform.php
lib/Doctrine/DBAL/Platforms/SqlitePlatform.php
+2
-2
Type.php
lib/Doctrine/DBAL/Types/Type.php
+6
-1
ClassExporter.php
lib/Doctrine/ORM/Export/ClassExporter.php
+1
-0
StandardHydrator.php
lib/Doctrine/ORM/Internal/Hydration/StandardHydrator.php
+9
-28
ClassMetadata.php
lib/Doctrine/ORM/Mapping/ClassMetadata.php
+3
-1
UnitOfWork.php
lib/Doctrine/ORM/UnitOfWork.php
+12
-10
BasicCRUDTest.php
tests/Orm/Functional/BasicCRUDTest.php
+11
-1
ClassMetadataFactoryTest.php
tests/Orm/Mapping/ClassMetadataFactoryTest.php
+2
-2
CmsUser.php
tests/models/cms/CmsUser.php
+1
-1
No files found.
lib/Doctrine/DBAL/Platforms/SqlitePlatform.php
View file @
b6e385d2
...
...
@@ -501,9 +501,9 @@ class Doctrine_DBAL_Platforms_SqlitePlatform extends Doctrine_DBAL_Platforms_Abs
}
}
if
(
!
$autoinc
&&
isset
(
$options
[
'primary'
])
&&
!
empty
(
$options
[
'primary'
]))
{
if
(
isset
(
$options
[
'primary'
])
&&
!
empty
(
$options
[
'primary'
]))
{
$keyColumns
=
array_values
(
$options
[
'primary'
]);
$keyColumns
=
array_map
(
array
(
$this
->
_conn
,
'quoteIdentifier'
),
$keyColumns
);
$keyColumns
=
array_map
(
array
(
$this
,
'quoteIdentifier'
),
$keyColumns
);
$queryFields
.=
', PRIMARY KEY('
.
implode
(
', '
,
$keyColumns
)
.
')'
;
}
...
...
lib/Doctrine/DBAL/Types/Type.php
View file @
b6e385d2
...
...
@@ -48,9 +48,14 @@ abstract class Doctrine_DBAL_Types_Type
*/
public
static
function
getType
(
$name
)
{
if
(
is_object
(
$name
))
{
try
{
throw
new
Exception
();
}
catch
(
Exception
$e
)
{
echo
$e
->
getTraceAsString
();
}
die
();
}
if
(
!
isset
(
self
::
$_typeObjects
[
$name
]))
{
if
(
!
isset
(
self
::
$_typesMap
[
$name
]))
{
throw
Doctrine_Exception
::
unknownType
(
$name
);
throw
new
Doctrine_Exception
(
"Unknown type:
$name
"
);
}
self
::
$_typeObjects
[
$name
]
=
new
self
::
$_typesMap
[
$name
]();
}
...
...
lib/Doctrine/ORM/Export/ClassExporter.php
View file @
b6e385d2
...
...
@@ -71,6 +71,7 @@ class Doctrine_ORM_Export_ClassExporter
$column
[
'length'
]
=
$mapping
[
'length'
];
if
(
$class
->
isIdentifier
(
$fieldName
))
{
$column
[
'primary'
]
=
true
;
if
(
$class
->
isIdGeneratorIdentity
())
{
$column
[
'autoincrement'
]
=
true
;
}
...
...
lib/Doctrine/ORM/Internal/Hydration/StandardHydrator.php
View file @
b6e385d2
...
...
@@ -327,6 +327,8 @@ class Doctrine_ORM_Internal_Hydration_StandardHydrator extends Doctrine_ORM_Inte
}
else
{
$fieldName
=
$this
->
_lookupFieldName
(
$classMetadata
,
$columnName
);
$cache
[
$key
][
'isScalar'
]
=
false
;
// cache type information
$cache
[
$key
][
'type'
]
=
$classMetadata
->
getTypeOfColumn
(
$columnName
);
}
$cache
[
$key
][
'fieldName'
]
=
$fieldName
;
...
...
@@ -337,15 +339,6 @@ class Doctrine_ORM_Internal_Hydration_StandardHydrator extends Doctrine_ORM_Inte
}
else
{
$cache
[
$key
][
'isIdentifier'
]
=
false
;
}
// cache type information
$type
=
$classMetadata
->
getTypeOfColumn
(
$columnName
);
if
(
$type
==
'integer'
||
$type
==
'string'
)
{
$cache
[
$key
][
'isSimpleType'
]
=
true
;
}
else
{
$cache
[
$key
][
'type'
]
=
$type
;
$cache
[
$key
][
'isSimpleType'
]
=
false
;
}
}
$class
=
$this
->
_queryComponents
[
$cache
[
$key
][
'dqlAlias'
]][
'metadata'
];
...
...
@@ -361,13 +354,11 @@ class Doctrine_ORM_Internal_Hydration_StandardHydrator extends Doctrine_ORM_Inte
$id
[
$dqlAlias
]
.=
'|'
.
$value
;
}
if
(
$cache
[
$key
][
'isS
impleType
'
])
{
if
(
$cache
[
$key
][
'isS
calar
'
])
{
$rowData
[
$dqlAlias
][
$fieldName
]
=
$value
;
}
else
{
$rowData
[
$dqlAlias
][
$fieldName
]
=
$this
->
prepareValue
(
$class
,
$fieldName
,
$value
,
$cache
[
$key
][
'type'
]);
$rowData
[
$dqlAlias
][
$fieldName
]
=
$cache
[
$key
][
'type'
]
->
convertToPHPValue
(
$value
);
}
//$rowData[$dqlAlias][$fieldName] = $cache[$key]['type']->convertToObjectValue($value);
if
(
!
isset
(
$nonemptyComponents
[
$dqlAlias
])
&&
$value
!==
null
)
{
$nonemptyComponents
[
$dqlAlias
]
=
true
;
...
...
@@ -412,31 +403,21 @@ class Doctrine_ORM_Internal_Hydration_StandardHydrator extends Doctrine_ORM_Inte
}
else
{
$fieldName
=
$this
->
_lookupFieldName
(
$classMetadata
,
$columnName
);
$cache
[
$key
][
'isScalar'
]
=
false
;
// cache type information
$cache
[
$key
][
'type'
]
=
$classMetadata
->
getTypeOfColumn
(
$columnName
);
}
$cache
[
$key
][
'fieldName'
]
=
$fieldName
;
// cache type information
$type
=
$classMetadata
->
getTypeOfColumn
(
$columnName
);
if
(
$type
==
'integer'
||
$type
==
'string'
)
{
$cache
[
$key
][
'isSimpleType'
]
=
true
;
}
else
{
$cache
[
$key
][
'type'
]
=
$type
;
$cache
[
$key
][
'isSimpleType'
]
=
false
;
}
}
$class
=
$this
->
_queryComponents
[
$cache
[
$key
][
'dqlAlias'
]][
'metadata'
];
$dqlAlias
=
$cache
[
$key
][
'dqlAlias'
];
$fieldName
=
$cache
[
$key
][
'fieldName'
];
if
(
$cache
[
$key
][
'isS
impleType'
]
||
$cache
[
$key
][
'isS
calar'
])
{
if
(
$cache
[
$key
][
'isScalar'
])
{
$rowData
[
$dqlAlias
.
'_'
.
$fieldName
]
=
$value
;
}
else
{
$rowData
[
$dqlAlias
.
'_'
.
$fieldName
]
=
$this
->
prepareValue
(
$class
,
$fieldName
,
$value
,
$cache
[
$key
][
'type'
]);
$rowData
[
$dqlAlias
.
'_'
.
$fieldName
]
=
$cache
[
$key
][
'type'
]
->
convertToPHPValue
(
$value
);
}
//$rowData[$dqlAlias . '_' . $fieldName] = $cache[$key]['type']->convertToObjectValue($value);
}
return
$rowData
;
...
...
@@ -526,7 +507,7 @@ class Doctrine_ORM_Internal_Hydration_StandardHydrator extends Doctrine_ORM_Inte
* @return mixed prepared value
* @todo Remove. Should be handled by the Type classes. No need for this switch stuff.
*/
public
function
prepareValue
(
Doctrine_ClassMetadata
$class
,
$fieldName
,
$value
,
$typeHint
=
null
)
public
function
prepareValue
(
Doctrine_
ORM_Mapping_
ClassMetadata
$class
,
$fieldName
,
$value
,
$typeHint
=
null
)
{
if
(
$value
===
$this
->
_nullObject
)
{
return
$this
->
_nullObject
;
...
...
lib/Doctrine/ORM/Mapping/ClassMetadata.php
View file @
b6e385d2
...
...
@@ -617,7 +617,9 @@ class Doctrine_ORM_Mapping_ClassMetadata
throw
Doctrine_ORM_Exceptions_MappingException
::
missingType
();
}
$mapping
[
'type'
]
=
Doctrine_DBAL_Types_Type
::
getType
(
$mapping
[
'type'
]);
if
(
!
is_object
(
$mapping
[
'type'
]))
{
$mapping
[
'type'
]
=
Doctrine_DBAL_Types_Type
::
getType
(
$mapping
[
'type'
]);
}
// Complete fieldName and columnName mapping
if
(
!
isset
(
$mapping
[
'columnName'
]))
{
...
...
lib/Doctrine/ORM/UnitOfWork.php
View file @
b6e385d2
...
...
@@ -257,13 +257,12 @@ class Doctrine_ORM_UnitOfWork
/**
* Computes all the changes that have been done to entities in the identity map
*
and stores these changes in _dataChangeSet temporarily for access by the
*
per
isters, until the UoW commit is finished.
*
since the last commit and stores these changes in _dataChangeSet temporarily
*
for access by the pers
isters, until the UoW commit is finished.
*
* @param array $entities The entities for which to compute the changesets. If this
* parameter is not specified, the changesets of all entities in the identity
* map are computed.
* @return void
*/
public
function
computeDataChangeSet
(
array
$entities
=
null
)
{
...
...
@@ -297,6 +296,7 @@ class Doctrine_ORM_UnitOfWork
if
(
$state
==
self
::
STATE_NEW
)
{
$this
->
_dataChangeSets
[
$oid
]
=
$actualData
;
$this
->
_originalEntityData
[
$oid
]
=
$actualData
;
}
else
{
$originalData
=
$this
->
_originalEntityData
[
$oid
];
$changeSet
=
array
();
...
...
@@ -308,13 +308,13 @@ class Doctrine_ORM_UnitOfWork
$changeSet
[
$propName
]
=
array
(
$orgValue
=>
$actualValue
);
}
}
$this
->
_dirtyEntities
[
$oid
]
=
$entity
;
$this
->
_dataChangeSets
[
$oid
]
=
$changeSet
;
if
(
$changeSet
)
{
$this
->
_dirtyEntities
[
$oid
]
=
$entity
;
$this
->
_dataChangeSets
[
$oid
]
=
$changeSet
;
$this
->
_originalEntityData
[
$oid
]
=
$actualData
;
}
}
}
if
(
isset
(
$this
->
_dirtyEntities
[
$oid
]))
{
$this
->
_originalEntityData
[
$oid
]
=
$actualData
;
}
}
}
}
...
...
@@ -337,10 +337,11 @@ class Doctrine_ORM_UnitOfWork
$returnVal
=
$persister
->
insert
(
$entity
);
if
(
!
is_null
(
$returnVal
))
{
$oid
=
spl_object_hash
(
$entity
);
$
class
->
getReflectionProperty
(
$class
->
getSingleIdentifierFieldName
())
->
setValue
(
$entity
,
$returnVal
);
$
idField
=
$class
->
getSingleIdentifierFieldName
();
$class
->
getReflectionProperty
(
$idField
)
->
setValue
(
$entity
,
$returnVal
);
$this
->
_entityIdentifiers
[
$oid
]
=
array
(
$returnVal
);
$this
->
_entityStates
[
$oid
]
=
self
::
STATE_MANAGED
;
$this
->
_originalEntityData
[
$oid
][
$idField
]
=
$returnVal
;
$this
->
addToIdentityMap
(
$entity
);
}
}
...
...
@@ -354,6 +355,7 @@ class Doctrine_ORM_UnitOfWork
*/
private
function
_executeUpdates
(
$class
)
{
try
{
throw
new
Exception
();
}
catch
(
Exception
$e
)
{
echo
$e
->
getTraceAsString
();
}
$className
=
$class
->
getClassName
();
$persister
=
$this
->
_em
->
getEntityPersister
(
$className
);
foreach
(
$this
->
_dirtyEntities
as
$entity
)
{
...
...
tests/Orm/Functional/BasicCRUDTest.php
View file @
b6e385d2
...
...
@@ -12,7 +12,10 @@ class Orm_Functional_BasicCRUDTest extends Doctrine_OrmFunctionalTestCase {
$em
=
$this
->
_getEntityManager
();
$exporter
=
new
Doctrine_ORM_Export_ClassExporter
(
$em
);
$exporter
->
exportClasses
(
array
(
$em
->
getClassMetadata
(
'CmsUser'
)));
$exporter
->
exportClasses
(
array
(
$em
->
getClassMetadata
(
'CmsUser'
),
$em
->
getClassMetadata
(
'CmsPhonenumber'
)
));
// Create
$user
=
new
CmsUser
;
...
...
@@ -33,6 +36,13 @@ class Orm_Functional_BasicCRUDTest extends Doctrine_OrmFunctionalTestCase {
$user4
=
$em
->
find
(
'CmsUser'
,
$user2
->
id
);
$this
->
assertTrue
(
$user2
===
$user4
);
$ph
=
new
CmsPhonenumber
;
$ph
->
phonenumber
=
"12345"
;
$user
->
phonenumbers
[]
=
$ph
;
//var_dump($em->getUnitOfWork())
}
}
tests/Orm/Mapping/ClassMetadataFactoryTest.php
View file @
b6e385d2
...
...
@@ -21,7 +21,7 @@ class Orm_Mapping_ClassMetadataFactoryTest extends Doctrine_OrmTestCase {
// Self-made metadata
$cm1
=
new
Doctrine_ORM_Mapping_ClassMetadata
(
'CMFTest_Entity1'
);
// Add a mapped field
$cm1
->
mapField
(
array
(
'fieldName'
=>
'name'
,
'type'
=>
'
string
'
));
$cm1
->
mapField
(
array
(
'fieldName'
=>
'name'
,
'type'
=>
'
varchar
'
));
// and a mapped association
$cm1
->
mapOneToOne
(
array
(
'fieldName'
=>
'other'
,
'targetEntity'
=>
'Other'
,
'mappedBy'
=>
'this'
));
// and an id generator type
...
...
@@ -56,7 +56,7 @@ class Orm_Mapping_ClassMetadataFactoryTest extends Doctrine_OrmTestCase {
$cm1
=
new
Doctrine_ORM_Mapping_ClassMetadata
(
'CMFTest_Entity1'
);
$cm1
->
setInheritanceType
(
'singleTable'
);
// Add a mapped field
$cm1
->
mapField
(
array
(
'fieldName'
=>
'name'
,
'type'
=>
'
string
'
));
$cm1
->
mapField
(
array
(
'fieldName'
=>
'name'
,
'type'
=>
'
varchar
'
));
// and a mapped association
$cm1
->
mapOneToOne
(
array
(
'fieldName'
=>
'other'
,
'targetEntity'
=>
'Other'
,
'mappedBy'
=>
'this'
));
// and an id generator type
...
...
tests/models/cms/CmsUser.php
View file @
b6e385d2
...
...
@@ -26,7 +26,7 @@ class CmsUser
*/
public
$name
;
/**
* @DoctrineOneToMany(targetEntity="CmsPhonenumber", mappedBy="user")
* @DoctrineOneToMany(targetEntity="CmsPhonenumber", mappedBy="user"
, cascade={"save"}
)
*/
public
$phonenumbers
;
/**
...
...
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