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
15f84f6e
Commit
15f84f6e
authored
Dec 03, 2009
by
romanb
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[2.0][DDC-187] Fixed. Also fixed some DBAL failures on postgres.
parent
73017b53
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
75 additions
and
10 deletions
+75
-10
PostgreSqlPlatform.php
lib/Doctrine/DBAL/Platforms/PostgreSqlPlatform.php
+2
-1
PostgreSqlSchemaManager.php
lib/Doctrine/DBAL/Schema/PostgreSqlSchemaManager.php
+4
-4
ObjectHydrator.php
lib/Doctrine/ORM/Internal/Hydration/ObjectHydrator.php
+1
-1
PostgreSqlPlatformTest.php
.../Doctrine/Tests/DBAL/Platforms/PostgreSqlPlatformTest.php
+1
-1
SingleTableInheritanceTest.php
...trine/Tests/ORM/Functional/SingleTableInheritanceTest.php
+67
-3
No files found.
lib/Doctrine/DBAL/Platforms/PostgreSqlPlatform.php
View file @
15f84f6e
...
...
@@ -341,7 +341,7 @@ class PostgreSqlPlatform extends AbstractPlatform
public
function
getListTableForeignKeysSql
(
$table
,
$database
=
null
)
{
return
"SELECT r.name, pg_catalog.pg_get_constraintdef(r.oid, true) as condef
return
"SELECT r.
con
name, pg_catalog.pg_get_constraintdef(r.oid, true) as condef
FROM pg_catalog.pg_constraint r
WHERE r.conrelid =
(
...
...
@@ -568,6 +568,7 @@ class PostgreSqlPlatform extends AbstractPlatform
{
return
'CREATE SEQUENCE '
.
$sequence
->
getName
()
.
' INCREMENT BY '
.
$sequence
->
getAllocationSize
()
.
' MINVALUE '
.
$sequence
->
getInitialValue
()
.
' START '
.
$sequence
->
getInitialValue
();
}
...
...
lib/Doctrine/DBAL/Schema/PostgreSqlSchemaManager.php
View file @
15f84f6e
...
...
@@ -52,7 +52,7 @@ class PostgreSqlSchemaManager extends AbstractSchemaManager
}
return
new
ForeignKeyConstraint
(
$localColumns
,
$foreignTable
,
$foreignColumns
,
$tableForeignKey
[
'name'
],
$localColumns
,
$foreignTable
,
$foreignColumns
,
$tableForeignKey
[
'
con
name'
],
array
(
'onUpdate'
=>
$onUpdate
,
'onDelete'
=>
$onDelete
)
);
}
...
...
@@ -87,7 +87,7 @@ class PostgreSqlSchemaManager extends AbstractSchemaManager
$this
->
_platform
=
$tmpPlatform
;
$this
->
_conn
=
$tmpConn
;
}
}
protected
function
_getPortableTriggerDefinition
(
$trigger
)
{
...
...
@@ -153,8 +153,8 @@ class PostgreSqlSchemaManager extends AbstractSchemaManager
protected
function
_getPortableSequenceDefinition
(
$sequence
)
{
$data
=
$this
->
_conn
->
fetchAll
(
'SELECT
start
_value, increment_by FROM '
.
$sequence
[
'relname'
]);
return
new
Sequence
(
$sequence
[
'relname'
],
$data
[
0
][
'increment_by'
],
$data
[
0
][
'
start
_value'
]);
$data
=
$this
->
_conn
->
fetchAll
(
'SELECT
min
_value, increment_by FROM '
.
$sequence
[
'relname'
]);
return
new
Sequence
(
$sequence
[
'relname'
],
$data
[
0
][
'increment_by'
],
$data
[
0
][
'
min
_value'
]);
}
protected
function
_getPortableTableConstraintDefinition
(
$tableConstraint
)
...
...
lib/Doctrine/ORM/Internal/Hydration/ObjectHydrator.php
View file @
15f84f6e
...
...
@@ -266,7 +266,7 @@ class ObjectHydrator extends AbstractHydrator
continue
;
}
$parentClass
=
get_class
(
$parentObject
)
;
$parentClass
=
$this
->
_rsm
->
aliasMap
[
$parentAlias
]
;
$oid
=
spl_object_hash
(
$parentObject
);
$relationField
=
$this
->
_rsm
->
relationMap
[
$dqlAlias
];
$relation
=
$this
->
_ce
[
$parentClass
]
->
associationMappings
[
$relationField
];
...
...
tests/Doctrine/Tests/DBAL/Platforms/PostgreSqlPlatformTest.php
View file @
15f84f6e
...
...
@@ -145,7 +145,7 @@ class PostgreSqlPlatformTest extends AbstractPlatformTestCase
{
$sequence
=
new
\Doctrine\DBAL\Schema\Sequence
(
'myseq'
,
20
,
1
);
$this
->
assertEquals
(
'CREATE SEQUENCE myseq INCREMENT BY 20 START 1'
,
'CREATE SEQUENCE myseq INCREMENT BY 20
MINVALUE 1
START 1'
,
$this
->
_platform
->
getCreateSequenceSql
(
$sequence
)
);
$this
->
assertEquals
(
...
...
tests/Doctrine/Tests/ORM/Functional/SingleTableInheritanceTest.php
View file @
15f84f6e
...
...
@@ -19,7 +19,8 @@ class SingleTableInheritanceTest extends \Doctrine\Tests\OrmFunctionalTestCase
$this
->
_schemaTool
->
createSchema
(
array
(
$this
->
_em
->
getClassMetadata
(
'Doctrine\Tests\ORM\Functional\ParentEntity'
),
$this
->
_em
->
getClassMetadata
(
'Doctrine\Tests\ORM\Functional\ChildEntity'
),
$this
->
_em
->
getClassMetadata
(
'Doctrine\Tests\ORM\Functional\RelatedEntity'
)
$this
->
_em
->
getClassMetadata
(
'Doctrine\Tests\ORM\Functional\RelatedEntity'
),
$this
->
_em
->
getClassMetadata
(
'Doctrine\Tests\ORM\Functional\ParentRelatedEntity'
)
));
}
catch
(
\Exception
$e
)
{
// Swallow all exceptions. We do not test the schema tool here.
...
...
@@ -56,7 +57,9 @@ class SingleTableInheritanceTest extends \Doctrine\Tests\OrmFunctionalTestCase
$this
->
assertTrue
(
is_numeric
(
$entities
[
0
]
->
getId
()));
$this
->
assertTrue
(
is_numeric
(
$entities
[
1
]
->
getId
()));
$this
->
assertTrue
(
$entities
[
0
]
instanceof
ParentEntity
);
$this
->
assertTrue
(
$entities
[
1
]
instanceof
ChildEntity
);
$this
->
assertTrue
(
$entities
[
1
]
instanceof
ChildEntity
);
$this
->
assertNull
(
$entities
[
0
]
->
getParentRelated
());
$this
->
assertNull
(
$entities
[
1
]
->
getParentRelated
());
$this
->
assertEquals
(
'foobar'
,
$entities
[
0
]
->
getData
());
$this
->
assertEquals
(
'thedata'
,
$entities
[
1
]
->
getData
());
$this
->
assertEquals
(
1234
,
$entities
[
1
]
->
getNumber
());
...
...
@@ -70,6 +73,7 @@ class SingleTableInheritanceTest extends \Doctrine\Tests\OrmFunctionalTestCase
$this
->
assertTrue
(
is_numeric
(
$entities
[
0
]
->
getId
()));
$this
->
assertEquals
(
'thedata'
,
$entities
[
0
]
->
getData
());
$this
->
assertEquals
(
1234
,
$entities
[
0
]
->
getNumber
());
$this
->
assertNull
(
$entities
[
0
]
->
getParentRelated
());
$this
->
_em
->
clear
();
...
...
@@ -83,6 +87,7 @@ class SingleTableInheritanceTest extends \Doctrine\Tests\OrmFunctionalTestCase
$this
->
assertTrue
(
$entities
[
0
]
->
getOwner
()
instanceof
ChildEntity
);
$this
->
assertEquals
(
'thedata'
,
$entities
[
0
]
->
getOwner
()
->
getData
());
$this
->
assertSame
(
$entities
[
0
],
$entities
[
0
]
->
getOwner
()
->
getRelatedEntity
());
$this
->
assertNull
(
$entities
[
0
]
->
getOwner
()
->
getParentRelated
());
$query
=
$this
->
_em
->
createQuery
(
"update Doctrine\Tests\ORM\Functional\ChildEntity e set e.data = 'newdata'"
);
...
...
@@ -114,6 +119,7 @@ class SingleTableInheritanceTest extends \Doctrine\Tests\OrmFunctionalTestCase
$this
->
assertEquals
(
1234
,
$child2
->
getNumber
());
$this
->
assertEquals
(
$child
->
getId
(),
$child2
->
getId
());
$this
->
assertFalse
(
$child
===
$child2
);
$this
->
assertNull
(
$child2
->
getParentRelated
());
}
public
function
testGetScalarResult
()
...
...
@@ -138,7 +144,7 @@ class SingleTableInheritanceTest extends \Doctrine\Tests\OrmFunctionalTestCase
$this
->
assertEquals
(
'child'
,
$result
[
0
][
'e_discr'
]);
}
public
function
testPolymorphicFind
()
public
function
testPolymorphicFind
AndQuery
()
{
$child
=
new
ChildEntity
;
$child
->
setData
(
'thedata'
);
...
...
@@ -154,7 +160,33 @@ class SingleTableInheritanceTest extends \Doctrine\Tests\OrmFunctionalTestCase
$this
->
assertTrue
(
$child2
instanceof
ChildEntity
);
$this
->
assertEquals
(
'thedata'
,
$child2
->
getData
());
$this
->
assertSame
(
1234
,
$child2
->
getNumber
());
$parentRelated
=
new
ParentRelatedEntity
;
$parentRelated
->
setData
(
'related to parent!'
);
$child2
->
setParentRelated
(
$parentRelated
);
$parentRelated
->
setParent
(
$child2
);
$this
->
_em
->
persist
(
$parentRelated
);
//$this->_em->getConnection()->getConfiguration()->setSqlLogger(new \Doctrine\DBAL\Logging\EchoSqlLogger);
$this
->
_em
->
flush
();
$this
->
_em
->
clear
();
$query
=
$this
->
_em
->
createQuery
(
"select p, r from Doctrine\Tests\ORM\Functional\ParentEntity p join p.parentRelated r"
);
$result
=
$query
->
getResult
();
$this
->
assertEquals
(
1
,
count
(
$result
));
$this
->
assertTrue
(
$result
[
0
]
instanceof
ChildEntity
);
$related
=
$result
[
0
]
->
getParentRelated
();
$this
->
assertFalse
(
$related
instanceof
\Doctrine\ORM\Proxy\Proxy
);
$this
->
assertTrue
(
$related
instanceof
ParentRelatedEntity
);
$this
->
assertEquals
(
'related to parent!'
,
$related
->
getData
());
}
/*public function testPolymorphicQueryWithJoin()
{
}*/
}
/**
...
...
@@ -175,6 +207,9 @@ class ParentEntity {
* @Column(name="DATA", type="string")
*/
private
$data
;
/** @OneToOne(targetEntity="ParentRelatedEntity", mappedBy="parent") */
private
$parentRelated
;
public
function
getId
()
{
return
$this
->
id
;
...
...
@@ -187,6 +222,14 @@ class ParentEntity {
public
function
setData
(
$data
)
{
$this
->
data
=
$data
;
}
public
function
getParentRelated
()
{
return
$this
->
parentRelated
;
}
public
function
setParentRelated
(
$parentRelated
)
{
$this
->
parentRelated
=
$parentRelated
;
}
}
/**
...
...
@@ -263,3 +306,24 @@ class RelatedEntity {
}
}
}
/** @Entity */
class
ParentRelatedEntity
{
/**
* @Id @Column(type="integer")
* @GeneratedValue(strategy="AUTO")
*/
private
$id
;
public
function
getId
()
{
return
$this
->
id
;}
/** @Column(type="string") */
private
$data
;
public
function
getData
()
{
return
$this
->
data
;}
public
function
setData
(
$data
)
{
$this
->
data
=
$data
;}
/**
* @OneToOne(targetEntity="ParentEntity")
* @JoinColumn(name="parent_id", referencedColumnName="id")
*/
private
$parent
;
public
function
getParent
()
{
return
$this
->
parent
;}
public
function
setParent
(
$parent
)
{
$this
->
parent
=
$parent
;}
}
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