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
f1559554
Commit
f1559554
authored
Jul 04, 2012
by
Benjamin Eberlei
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Merge master into 2.2
parent
8cc129aa
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
30 additions
and
7 deletions
+30
-7
Index.php
lib/Doctrine/DBAL/Schema/Index.php
+14
-6
IndexTest.php
tests/Doctrine/Tests/DBAL/Schema/IndexTest.php
+16
-1
No files found.
lib/Doctrine/DBAL/Schema/Index.php
View file @
f1559554
...
@@ -77,6 +77,14 @@ class Index extends AbstractAsset implements Constraint
...
@@ -77,6 +77,14 @@ class Index extends AbstractAsset implements Constraint
return
$this
->
_columns
;
return
$this
->
_columns
;
}
}
/**
* @return array
*/
public
function
getUnquotedColumns
()
{
return
array_map
(
array
(
$this
,
'trimQuotes'
),
$this
->
getColumns
());
}
/**
/**
* Is the index neither unique nor primary key?
* Is the index neither unique nor primary key?
*
*
...
@@ -108,11 +116,11 @@ class Index extends AbstractAsset implements Constraint
...
@@ -108,11 +116,11 @@ class Index extends AbstractAsset implements Constraint
* @param int $pos
* @param int $pos
* @return bool
* @return bool
*/
*/
public
function
hasColumnAtPosition
(
$columnName
,
$pos
=
0
)
public
function
hasColumnAtPosition
(
$columnName
,
$pos
=
0
)
{
{
$columnName
=
strtolower
(
$columnName
);
$columnName
=
$this
->
trimQuotes
(
strtolower
(
$columnName
)
);
$indexColumns
=
\array_map
(
'strtolower'
,
$this
->
get
Columns
());
$indexColumns
=
array_map
(
'strtolower'
,
$this
->
getUnquoted
Columns
());
return
\
array_search
(
$columnName
,
$indexColumns
)
===
$pos
;
return
array_search
(
$columnName
,
$indexColumns
)
===
$pos
;
}
}
/**
/**
...
@@ -125,7 +133,7 @@ class Index extends AbstractAsset implements Constraint
...
@@ -125,7 +133,7 @@ class Index extends AbstractAsset implements Constraint
{
{
$sameColumns
=
true
;
$sameColumns
=
true
;
for
(
$i
=
0
;
$i
<
count
(
$this
->
_columns
);
$i
++
)
{
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
;
$sameColumns
=
false
;
}
}
}
}
...
@@ -185,4 +193,4 @@ class Index extends AbstractAsset implements Constraint
...
@@ -185,4 +193,4 @@ class Index extends AbstractAsset implements Constraint
}
}
return
false
;
return
false
;
}
}
}
}
\ No newline at end of file
tests/Doctrine/Tests/DBAL/Schema/IndexTest.php
View file @
f1559554
...
@@ -81,4 +81,19 @@ class IndexTest extends \PHPUnit_Framework_TestCase
...
@@ -81,4 +81,19 @@ class IndexTest extends \PHPUnit_Framework_TestCase
$this
->
assertTrue
(
$idx1
->
isFullfilledBy
(
$pri
));
$this
->
assertTrue
(
$idx1
->
isFullfilledBy
(
$pri
));
$this
->
assertTrue
(
$idx1
->
isFullfilledBy
(
$uniq
));
$this
->
assertTrue
(
$idx1
->
isFullfilledBy
(
$uniq
));
}
}
}
\ No newline at end of file
/**
* @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