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
d9969901
Commit
d9969901
authored
May 12, 2010
by
Benjamin Eberlei
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
DDC-515 - Fixed some issues with Schema Validation Command
parent
57cd2e01
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
46 additions
and
38 deletions
+46
-38
ValidateSchemaCommand.php
...trine/ORM/Tools/Console/Command/ValidateSchemaCommand.php
+3
-1
SchemaValidator.php
lib/Doctrine/ORM/Tools/SchemaValidator.php
+43
-37
No files found.
lib/Doctrine/ORM/Tools/Console/Command/ValidateSchemaCommand.php
View file @
d9969901
...
@@ -66,13 +66,15 @@ EOT
...
@@ -66,13 +66,15 @@ EOT
$exit
=
0
;
$exit
=
0
;
if
(
$errors
)
{
if
(
$errors
)
{
foreach
(
$errors
AS
$className
=>
$errorMessages
)
{
foreach
(
$errors
AS
$className
=>
$errorMessages
)
{
$output
->
write
(
"<error>[Mapping] FAIL - The entity-class '"
.
$className
.
"' mapping is invalid:</error>
\n
"
);
$output
->
write
(
"<error>[Mapping]
FAIL - The entity-class '"
.
$className
.
"' mapping is invalid:</error>
\n
"
);
foreach
(
$errorMessages
AS
$errorMessage
)
{
foreach
(
$errorMessages
AS
$errorMessage
)
{
$output
->
write
(
'* '
.
$errorMessage
.
"
\n
"
);
$output
->
write
(
'* '
.
$errorMessage
.
"
\n
"
);
}
}
$output
->
write
(
"
\n
"
);
$output
->
write
(
"
\n
"
);
}
}
$exit
+=
1
;
$exit
+=
1
;
}
else
{
$output
->
write
(
'<info>[Mapping] OK - The mapping files are correct.</info>'
.
"
\n
"
);
}
}
if
(
!
$validator
->
schemaInSyncWithMetadata
())
{
if
(
!
$validator
->
schemaInSyncWithMetadata
())
{
...
...
lib/Doctrine/ORM/Tools/SchemaValidator.php
View file @
d9969901
...
@@ -130,47 +130,53 @@ class SchemaValidator
...
@@ -130,47 +130,53 @@ class SchemaValidator
}
}
}
}
if
(
$assoc
instanceof
ManyToManyMapping
&&
$assoc
->
isOwningSide
)
{
if
(
$assoc
->
isOwningSide
)
{
foreach
(
$assoc
->
joinTable
[
'joinColumns'
]
AS
$joinColumn
)
{
if
(
$assoc
instanceof
ManyToManyMapping
)
{
if
(
!
isset
(
$class
->
fieldNames
[
$joinColumn
[
'referencedColumnName'
]]))
{
foreach
(
$assoc
->
joinTable
[
'joinColumns'
]
AS
$joinColumn
)
{
$ce
[]
=
"The referenced column name '"
.
$joinColumn
[
'referencedColumnName'
]
.
"' does not "
.
if
(
!
isset
(
$class
->
fieldNames
[
$joinColumn
[
'referencedColumnName'
]]))
{
"have a corresponding field with this column name on the class '"
.
$class
->
name
.
"'."
;
$ce
[]
=
"The referenced column name '"
.
$joinColumn
[
'referencedColumnName'
]
.
"' does not "
.
break
;
"have a corresponding field with this column name on the class '"
.
$class
->
name
.
"'."
;
break
;
}
$fieldName
=
$class
->
fieldNames
[
$joinColumn
[
'referencedColumnName'
]];
if
(
!
in_array
(
$fieldName
,
$class
->
identifier
))
{
$ce
[]
=
"The referenced column name '"
.
$joinColumn
[
'referencedColumnName'
]
.
"' "
.
"has to be a primary key column."
;
}
}
}
foreach
(
$assoc
->
joinTable
[
'inverseJoinColumns'
]
AS
$inverseJoinColumn
)
{
$fieldName
=
$class
->
fieldNames
[
$joinColumn
[
'referencedColumnName'
]];
$targetClass
=
$cmf
->
getMetadataFor
(
$assoc
->
targetEntityName
);
if
(
!
in_array
(
$fieldName
,
$class
->
identifier
))
{
if
(
!
isset
(
$targetClass
->
fieldNames
[
$inverseJoinColumn
[
'referencedColumnName'
]]))
{
$ce
[]
=
"The referenced column name '"
.
$joinColumn
[
'referencedColumnName'
]
.
"' "
.
$ce
[]
=
"The inverse referenced column name '"
.
$inverseJoinColumn
[
'referencedColumnName'
]
.
"' does not "
.
"has to be a primary key column."
;
"have a corresponding field with this column name on the class '"
.
$targetClass
->
name
.
"'."
;
}
break
;
}
}
foreach
(
$assoc
->
joinTable
[
'inverseJoinColumns'
]
AS
$inverseJoinColumn
)
{
if
(
!
isset
(
$class
->
fieldNames
[
$inverseJoinColumn
[
'referencedColumnName'
]]))
{
$fieldName
=
$targetClass
->
fieldNames
[
$inverseJoinColumn
[
'referencedColumnName'
]];
$ce
[]
=
"The referenced column name '"
.
$inverseJoinColumn
[
'referencedColumnName'
]
.
"' does not "
.
if
(
!
in_array
(
$fieldName
,
$targetClass
->
identifier
))
{
"have a corresponding field with this column name on the class '"
.
$class
->
name
.
"'."
;
$ce
[]
=
"The referenced column name '"
.
$inverseJoinColumn
[
'referencedColumnName'
]
.
"' "
.
break
;
"has to be a primary key column."
;
}
}
$fieldName
=
$class
->
fieldNames
[
$inverseJoinColumn
[
'referencedColumnName'
]];
if
(
!
in_array
(
$fieldName
,
$class
->
identifier
))
{
$ce
[]
=
"The referenced column name '"
.
$inverseJoinColumn
[
'referencedColumnName'
]
.
"' "
.
"has to be a primary key column."
;
}
}
}
else
if
(
$assoc
instanceof
OneToOneMapping
)
{
foreach
(
$assoc
->
joinColumns
AS
$joinColumn
)
{
if
(
!
isset
(
$class
->
fieldNames
[
$joinColumn
[
'referencedColumnName'
]]))
{
$ce
[]
=
"The referenced column name '"
.
$joinColumn
[
'referencedColumnName'
]
.
"' does not "
.
"have a corresponding field with this column name on the class '"
.
$class
->
name
.
"'."
;
break
;
}
}
}
else
if
(
$assoc
instanceof
OneToOneMapping
)
{
$fieldName
=
$class
->
fieldNames
[
$joinColumn
[
'referencedColumnName'
]];
foreach
(
$assoc
->
joinColumns
AS
$joinColumn
)
{
if
(
!
in_array
(
$fieldName
,
$class
->
identifier
))
{
$targetClass
=
$cmf
->
getMetadataFor
(
$assoc
->
targetEntityName
);
$ce
[]
=
"The referenced column name '"
.
$joinColumn
[
'referencedColumnName'
]
.
"' "
.
if
(
!
isset
(
$targetClass
->
fieldNames
[
$joinColumn
[
'referencedColumnName'
]]))
{
"has to be a primary key column."
;
$ce
[]
=
"The referenced column name '"
.
$joinColumn
[
'referencedColumnName'
]
.
"' does not "
.
"have a corresponding field with this column name on the class '"
.
$targetClass
->
name
.
"'."
;
break
;
}
$fieldName
=
$targetClass
->
fieldNames
[
$joinColumn
[
'referencedColumnName'
]];
if
(
!
in_array
(
$fieldName
,
$targetClass
->
identifier
))
{
$ce
[]
=
"The referenced column name '"
.
$joinColumn
[
'referencedColumnName'
]
.
"' "
.
"has to be a primary key column."
;
}
}
}
}
}
}
else
{
}
}
if
(
$ce
)
{
if
(
$ce
)
{
...
...
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