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
8a0898d3
Commit
8a0898d3
authored
Jul 30, 2007
by
romanb
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Several fixes for mysql export module (incorrectly added indices)
Ticket: 408
parent
7583a8d8
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
963 additions
and
959 deletions
+963
-959
Mysql.php
lib/Doctrine/Export/Mysql.php
+634
-629
MysqlTestCase.php
tests/Export/MysqlTestCase.php
+288
-289
model.php
tests/Export/_files2/model.php
+41
-41
No files found.
lib/Doctrine/Export/Mysql.php
View file @
8a0898d3
...
...
@@ -101,15 +101,20 @@ class Doctrine_Export_Mysql extends Doctrine_Export
if
(
isset
(
$options
[
'foreignKeys'
]))
{
foreach
(
$options
[
'foreignKeys'
]
as
$fk
)
{
$local
=
$fk
[
'local'
];
$found
=
false
;
if
(
isset
(
$options
[
'indexes'
]))
{
foreach
(
$options
[
'indexes'
]
as
$definition
)
{
if
(
isset
(
$definition
[
'fields'
][
$local
])
&&
count
(
$definition
[
'fields'
])
===
1
)
{
if
(
in_array
(
$local
,
$definition
[
'fields'
])
&&
count
(
$definition
[
'fields'
])
===
1
)
{
// Index already exists on the column
$found
=
true
;
}
}
}
if
(
isset
(
$options
[
'primary'
])
&&
!
empty
(
$options
[
'primary'
])
&&
in_array
(
$local
,
$options
[
'primary'
]))
{
// field is part of the PK and therefore already indexed
$found
=
true
;
}
if
(
!
$found
)
{
$options
[
'indexes'
][
$local
]
=
array
(
'fields'
=>
array
(
$local
=>
array
()));
...
...
tests/Export/MysqlTestCase.php
View file @
8a0898d3
...
...
@@ -200,12 +200,11 @@ class Doctrine_Export_Mysql_TestCase extends Doctrine_UnitTestCase
'foreignKeys'
=>
array
(
array
(
'local'
=>
'foreignKey'
,
'foreign'
=>
'id'
,
'foreignTable'
=>
'sometable'
)),
'indexes'
=>
array
(
'myindex'
=>
array
(
'fields'
=>
array
(
'foreignKey'
=>
array
()))),
'indexes'
=>
array
(
'myindex'
=>
array
(
'fields'
=>
array
(
'foreignKey'
))),
);
$sql
=
$this
->
export
->
createTableSql
(
$name
,
$fields
,
$options
);
$this
->
assertEqual
(
$sql
[
0
],
'CREATE TABLE mytable (id TINYINT(1), foreignKey INT, INDEX myindex_idx (foreignKey)) ENGINE = INNODB'
);
$this
->
assertEqual
(
$sql
[
1
],
'ALTER TABLE mytable ADD CONSTRAINT FOREIGN KEY (foreignKey) REFERENCES sometable(id)'
);
}
...
...
tests/Export/_files2/model.php
View file @
8a0898d3
...
...
@@ -15,8 +15,8 @@ class Cms_CategoryLanguages extends Doctrine_Record
$this
->
option
(
'collate'
,
'utf8_unicode_ci'
);
$this
->
option
(
'charset'
,
'utf8'
);
$this
->
option
(
'type'
,
'INNODB'
);
$this
->
index
(
'index_category'
,
array
(
'fields'
=>
'category_id'
));
$this
->
index
(
'index_language'
,
array
(
'fields'
=>
'language_id'
));
$this
->
index
(
'index_category'
,
array
(
'fields'
=>
array
(
'category_id'
)));
$this
->
index
(
'index_language'
,
array
(
'fields'
=>
array
(
'language_id'
)));
}
}
class
Cms_Category
extends
Doctrine_Record
...
...
@@ -36,6 +36,6 @@ class Cms_Category extends Doctrine_Record
$this
->
option
(
'collate'
,
'utf8_unicode_ci'
);
$this
->
option
(
'charset'
,
'utf8'
);
$this
->
option
(
'type'
,
'INNODB'
);
$this
->
index
(
'index_parent'
,
array
(
'fields'
=>
'parent'
));
$this
->
index
(
'index_parent'
,
array
(
'fields'
=>
array
(
'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