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
fdd1954a
Commit
fdd1954a
authored
Nov 11, 2009
by
jwage
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[2.0][DDC-72] Fixes issue with converting D1 column aliases to D2 field names
parent
fa404678
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
22 additions
and
8 deletions
+22
-8
ConvertDoctrine1Schema.php
lib/Doctrine/ORM/Tools/ConvertDoctrine1Schema.php
+9
-3
YamlExporter.php
lib/Doctrine/ORM/Tools/Export/Driver/YamlExporter.php
+8
-4
ConvertDoctrine1SchemaTest.php
...s/Doctrine/Tests/ORM/Tools/ConvertDoctrine1SchemaTest.php
+3
-1
schema.yml
tests/Doctrine/Tests/ORM/Tools/doctrine1schema/schema.yml
+2
-0
No files found.
lib/Doctrine/ORM/Tools/ConvertDoctrine1Schema.php
View file @
fdd1954a
...
...
@@ -150,13 +150,19 @@ class ConvertDoctrine1Schema
$column
=
array
();
$column
[
'type'
]
=
$string
;
}
if
(
!
isset
(
$column
[
'name'
]))
{
$column
[
'name'
]
=
$name
;
}
// check if a column alias was used (column_name as field_name)
if
(
preg_match
(
"/(\w+)\sas\s(\w+)/i"
,
$column
[
'name'
],
$matches
))
{
$name
=
$matches
[
1
];
$column
[
'name'
]
=
$name
;
$column
[
'alias'
]
=
$matches
[
2
];
}
if
(
preg_match
(
"/([a-zA-Z]+)\(([0-9]+)\)/"
,
$column
[
'type'
],
$matches
))
{
$column
[
'type'
]
=
$matches
[
1
];
$column
[
'length'
]
=
$matches
[
2
];
}
if
(
!
isset
(
$column
[
'name'
]))
{
$column
[
'name'
]
=
$name
;
}
$column
[
'type'
]
=
strtolower
(
$column
[
'type'
]);
// check if legacy column type (1.x) needs to be mapped to a 2.0 one
if
(
isset
(
$this
->
_legacyTypeMap
[
$column
[
'type'
]]))
{
...
...
lib/Doctrine/ORM/Tools/Export/Driver/YamlExporter.php
View file @
fdd1954a
...
...
@@ -106,10 +106,14 @@ class YamlExporter extends AbstractExporter
unset
(
$fieldMapping
[
'length'
]);
}
unset
(
$fieldMapping
[
'fieldName'
]);
if
(
$fieldMapping
[
'columnName'
]
==
$name
)
{
unset
(
$fieldMapping
[
'columnName'
]);
$fieldMapping
[
'column'
]
=
$fieldMapping
[
'columnName'
];
unset
(
$fieldMapping
[
'columnName'
],
$fieldMapping
[
'fieldName'
]
);
if
(
$fieldMapping
[
'column'
]
==
$name
)
{
unset
(
$fieldMapping
[
'column'
]);
}
if
(
isset
(
$fieldMapping
[
'id'
])
&&
$fieldMapping
[
'id'
])
{
...
...
tests/Doctrine/Tests/ORM/Tools/ConvertDoctrine1SchemaTest.php
View file @
fdd1954a
...
...
@@ -57,8 +57,10 @@ class ConvertDoctrine1SchemaTest extends \Doctrine\Tests\OrmTestCase
$this
->
assertEquals
(
'Profile'
,
$metadatas
[
'Profile'
]
->
name
);
$this
->
assertEquals
(
'User'
,
$metadatas
[
'User'
]
->
name
);
$this
->
assertEquals
(
4
,
count
(
$metadatas
[
'Profile'
]
->
fieldMappings
));
$this
->
assertEquals
(
4
,
count
(
$metadatas
[
'User'
]
->
fieldMappings
));
$this
->
assertEquals
(
5
,
count
(
$metadatas
[
'User'
]
->
fieldMappings
));
$this
->
assertEquals
(
'text'
,
$metadatas
[
'User'
]
->
fieldMappings
[
'clob'
][
'type'
]);
$this
->
assertEquals
(
'test_alias'
,
$metadatas
[
'User'
]
->
fieldMappings
[
'theAlias'
][
'columnName'
]);
$this
->
assertEquals
(
'theAlias'
,
$metadatas
[
'User'
]
->
fieldMappings
[
'theAlias'
][
'fieldName'
]);
$this
->
assertEquals
(
'Profile'
,
$metadatas
[
'Profile'
]
->
associationMappings
[
'User'
]
->
sourceEntityName
);
$this
->
assertEquals
(
'User'
,
$metadatas
[
'Profile'
]
->
associationMappings
[
'User'
]
->
targetEntityName
);
...
...
tests/Doctrine/Tests/ORM/Tools/doctrine1schema/schema.yml
View file @
fdd1954a
...
...
@@ -9,6 +9,8 @@ User:
password
:
type
:
string(255)
clob
:
clob
test_alias as theAlias
:
type
:
string(255)
indexes
:
username
:
fields
:
[
username
]
...
...
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