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
802d1366
Commit
802d1366
authored
Jul 04, 2012
by
Benjamin Eberlei
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[DBAL-285] Fix index comparing
parent
80201a10
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
28 additions
and
5 deletions
+28
-5
Index.php
lib/Doctrine/DBAL/Schema/Index.php
+13
-5
IndexTest.php
tests/Doctrine/Tests/DBAL/Schema/IndexTest.php
+15
-0
No files found.
lib/Doctrine/DBAL/Schema/Index.php
View file @
802d1366
...
...
@@ -87,6 +87,14 @@ class Index extends AbstractAsset implements Constraint
return
$this
->
_columns
;
}
/**
* @return array
*/
public
function
getUnquotedColumns
()
{
return
array_map
(
array
(
$this
,
'trimQuotes'
),
$this
->
getColumns
());
}
/**
* Is the index neither unique nor primary key?
*
...
...
@@ -118,11 +126,11 @@ class Index extends AbstractAsset implements Constraint
* @param int $pos
* @return bool
*/
public
function
hasColumnAtPosition
(
$columnName
,
$pos
=
0
)
public
function
hasColumnAtPosition
(
$columnName
,
$pos
=
0
)
{
$columnName
=
strtolower
(
$columnName
);
$indexColumns
=
\array_map
(
'strtolower'
,
$this
->
get
Columns
());
return
\
array_search
(
$columnName
,
$indexColumns
)
===
$pos
;
$columnName
=
$this
->
trimQuotes
(
strtolower
(
$columnName
)
);
$indexColumns
=
array_map
(
'strtolower'
,
$this
->
getUnquoted
Columns
());
return
array_search
(
$columnName
,
$indexColumns
)
===
$pos
;
}
/**
...
...
@@ -135,7 +143,7 @@ class Index extends AbstractAsset implements Constraint
{
$sameColumns
=
true
;
for
(
$i
=
0
;
$i
<
count
(
$this
->
_columns
);
$i
++
)
{
if
(
!
isset
(
$columnNames
[
$i
])
||
strtolower
(
$this
->
_columns
[
$i
])
!=
strtolower
(
$columnNames
[
$i
]
))
{
if
(
!
isset
(
$columnNames
[
$i
])
||
$this
->
trimQuotes
(
strtolower
(
$this
->
_columns
[
$i
]))
!=
$this
->
trimQuotes
(
strtolower
(
$columnNames
[
$i
])
))
{
$sameColumns
=
false
;
}
}
...
...
tests/Doctrine/Tests/DBAL/Schema/IndexTest.php
View file @
802d1366
...
...
@@ -97,4 +97,19 @@ class IndexTest extends \PHPUnit_Framework_TestCase
$idx1
->
removeFlag
(
'clustered'
);
$this
->
assertFalse
(
$idx1
->
hasFlag
(
'clustered'
));
}
/**
* @group DBAL-285
*/
public
function
testIndexQuotes
()
{
$index
=
new
Index
(
"foo"
,
array
(
"`bar`"
,
"`baz`"
));
$this
->
assertTrue
(
$index
->
spansColumns
(
array
(
"bar"
,
"baz"
)));
$this
->
assertTrue
(
$index
->
hasColumnAtPosition
(
"bar"
,
0
));
$this
->
assertTrue
(
$index
->
hasColumnAtPosition
(
"baz"
,
1
));
$this
->
assertFalse
(
$index
->
hasColumnAtPosition
(
"bar"
,
1
));
$this
->
assertFalse
(
$index
->
hasColumnAtPosition
(
"baz"
,
0
));
}
}
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