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
ddb5a66f
Commit
ddb5a66f
authored
Dec 07, 2009
by
romanb
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[2.0][DDC-191][DDC-192] Attempt to fix both.
parent
5730a32d
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
85 additions
and
12 deletions
+85
-12
Table.php
lib/Doctrine/DBAL/Schema/Table.php
+3
-3
SchemaTool.php
lib/Doctrine/ORM/Tools/SchemaTool.php
+10
-4
SingleTableInheritanceTest.php
...trine/Tests/ORM/Functional/SingleTableInheritanceTest.php
+0
-4
AllTests.php
tests/Doctrine/Tests/ORM/Functional/Ticket/AllTests.php
+1
-1
DDC192Test.php
tests/Doctrine/Tests/ORM/Functional/Ticket/DDC192Test.php
+71
-0
No files found.
lib/Doctrine/DBAL/Schema/Table.php
View file @
ddb5a66f
...
@@ -188,7 +188,7 @@ class Table extends AbstractAsset
...
@@ -188,7 +188,7 @@ class Table extends AbstractAsset
$columnName
=
$indexColOptions
;
$columnName
=
$indexColOptions
;
}
}
if
(
!
isset
(
$this
->
_columns
[
$columnName
]
))
{
if
(
!
$this
->
hasColumn
(
$columnName
))
{
throw
SchemaException
::
columnDoesNotExist
(
$columnName
);
throw
SchemaException
::
columnDoesNotExist
(
$columnName
);
}
}
}
}
...
@@ -304,7 +304,7 @@ class Table extends AbstractAsset
...
@@ -304,7 +304,7 @@ class Table extends AbstractAsset
$foreignTableName
=
$foreignTable
->
getName
();
$foreignTableName
=
$foreignTable
->
getName
();
foreach
(
$foreignColumnNames
AS
$columnName
)
{
foreach
(
$foreignColumnNames
AS
$columnName
)
{
if
(
!
$foreignTable
->
hasColumn
(
$columnName
))
{
if
(
!
$foreignTable
->
hasColumn
(
$columnName
))
{
throw
SchemaException
::
columnDoesNotExist
(
$columnName
);
throw
SchemaException
::
columnDoesNotExist
(
$columnName
);
}
}
}
}
...
@@ -313,7 +313,7 @@ class Table extends AbstractAsset
...
@@ -313,7 +313,7 @@ class Table extends AbstractAsset
}
}
foreach
(
$localColumnNames
AS
$columnName
)
{
foreach
(
$localColumnNames
AS
$columnName
)
{
if
(
!
$this
->
hasColumn
(
$columnName
))
{
if
(
!
$this
->
hasColumn
(
$columnName
))
{
throw
SchemaException
::
columnDoesNotExist
(
$columnName
);
throw
SchemaException
::
columnDoesNotExist
(
$columnName
);
}
}
}
}
...
...
lib/Doctrine/ORM/Tools/SchemaTool.php
View file @
ddb5a66f
...
@@ -384,6 +384,7 @@ class SchemaTool
...
@@ -384,6 +384,7 @@ class SchemaTool
$fkOptions
=
array
();
$fkOptions
=
array
();
foreach
(
$joinColumns
as
$joinColumn
)
{
foreach
(
$joinColumns
as
$joinColumn
)
{
// Note that this thing might be quoted, i.e. `foo`, [foo], ...
$columnName
=
$mapping
->
getQuotedJoinColumnName
(
$joinColumn
[
'name'
],
$this
->
_platform
);
$columnName
=
$mapping
->
getQuotedJoinColumnName
(
$joinColumn
[
'name'
],
$this
->
_platform
);
if
(
!
$class
->
hasField
(
$class
->
getFieldName
(
$joinColumn
[
'referencedColumnName'
])))
{
if
(
!
$class
->
hasField
(
$class
->
getFieldName
(
$joinColumn
[
'referencedColumnName'
])))
{
...
@@ -397,11 +398,16 @@ class SchemaTool
...
@@ -397,11 +398,16 @@ class SchemaTool
$localColumns
[]
=
$columnName
;
$localColumns
[]
=
$columnName
;
$foreignColumns
[]
=
$joinColumn
[
'referencedColumnName'
];
$foreignColumns
[]
=
$joinColumn
[
'referencedColumnName'
];
$theJoinTable
->
createColumn
(
if
(
!
$theJoinTable
->
hasColumn
(
$joinColumn
[
'name'
]))
{
$columnName
,
$class
->
getTypeOfColumn
(
$joinColumn
[
'referencedColumnName'
]),
array
(
'notnull'
=>
false
)
// Only add the column to the table if it does not exist already.
);
// It might exist already if the foreign key is mapped into a regular
// property as well.
$theJoinTable
->
createColumn
(
$columnName
,
$class
->
getTypeOfColumn
(
$joinColumn
[
'referencedColumnName'
]),
array
(
'notnull'
=>
false
)
);
}
if
(
isset
(
$joinColumn
[
'unique'
])
&&
$joinColumn
[
'unique'
]
==
true
)
{
if
(
isset
(
$joinColumn
[
'unique'
])
&&
$joinColumn
[
'unique'
]
==
true
)
{
$uniqueConstraints
[]
=
array
(
$columnName
);
$uniqueConstraints
[]
=
array
(
$columnName
);
}
}
...
...
tests/Doctrine/Tests/ORM/Functional/SingleTableInheritanceTest.php
View file @
ddb5a66f
...
@@ -183,10 +183,6 @@ class SingleTableInheritanceTest extends \Doctrine\Tests\OrmFunctionalTestCase
...
@@ -183,10 +183,6 @@ class SingleTableInheritanceTest extends \Doctrine\Tests\OrmFunctionalTestCase
$this
->
assertEquals
(
'related to parent!'
,
$related
->
getData
());
$this
->
assertEquals
(
'related to parent!'
,
$related
->
getData
());
}
}
/*public function testPolymorphicQueryWithJoin()
{
}*/
}
}
/**
/**
...
...
tests/Doctrine/Tests/ORM/Functional/Ticket/AllTests.php
View file @
ddb5a66f
...
@@ -19,7 +19,7 @@ class AllTests
...
@@ -19,7 +19,7 @@ class AllTests
{
{
$suite
=
new
\Doctrine\Tests\OrmFunctionalTestSuite
(
'Doctrine Orm Ticket Tests'
);
$suite
=
new
\Doctrine\Tests\OrmFunctionalTestSuite
(
'Doctrine Orm Ticket Tests'
);
$tests
=
glob
(
__DIR__
.
'/
Ticket
*Test.php'
);
$tests
=
glob
(
__DIR__
.
'/*Test.php'
);
foreach
(
$tests
as
$test
)
{
foreach
(
$tests
as
$test
)
{
$info
=
pathinfo
(
$test
);
$info
=
pathinfo
(
$test
);
$suite
->
addTestSuite
(
'Doctrine\Tests\ORM\Functional\Ticket\\'
.
$info
[
'filename'
]);
$suite
->
addTestSuite
(
'Doctrine\Tests\ORM\Functional\Ticket\\'
.
$info
[
'filename'
]);
...
...
tests/Doctrine/Tests/ORM/Functional/Ticket/DDC192Test.php
0 → 100644
View file @
ddb5a66f
<?php
namespace
Doctrine\Tests\ORM\Functional\Ticket
;
require_once
__DIR__
.
'/../../../TestInit.php'
;
class
DDC192Test
extends
\Doctrine\Tests\OrmFunctionalTestCase
{
public
function
testSchemaCreation
()
{
$this
->
_schemaTool
->
createSchema
(
array
(
$this
->
_em
->
getClassMetadata
(
__NAMESPACE__
.
'\DDC192User'
),
$this
->
_em
->
getClassMetadata
(
__NAMESPACE__
.
'\DDC192Phonenumber'
)
));
}
}
/**
* @Entity @Table(name="ddc192_users")
*/
class
DDC192User
{
/**
* @Id @Column(name="id", type="integer")
* @GeneratedValue(strategy="AUTO")
*/
public
$id
;
/**
* @Column(name="name", type="string")
*/
public
$name
;
}
/**
* @Entity @Table(name="ddc192_phonenumbers")
*/
class
DDC192Phonenumber
{
/**
* @Id @Column(name="phone", type="string", length=40)
*/
protected
$phone
;
/**
* @Id @Column(name="userId", type="integer")
*/
protected
$userId
;
/**
* @Id
* @ManyToOne(targetEntity="DDC192User")
* @JoinColumn(name="userId", referencedColumnName="id")
*/
protected
$User
;
// Id on this docblock is ignored!
public
function
setPhone
(
$value
)
{
$this
->
phone
=
$value
;
}
public
function
getPhone
()
{
return
$this
->
phone
;
}
public
function
setUser
(
User
$user
)
{
$this
->
User
=
$user
;
$this
->
userId
=
$user
->
getId
();
// TODO: Remove once ManyToOne supports Id annotation
}
public
function
getUser
()
{
return
$this
->
User
;
}
}
\ No newline at end of file
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