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
2cb22496
Commit
2cb22496
authored
Jun 26, 2011
by
Benjamin Eberlei
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix bug in Index::overrules()
parent
4cfb32db
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
28 additions
and
1 deletion
+28
-1
Index.php
lib/Doctrine/DBAL/Schema/Index.php
+13
-1
TableTest.php
tests/Doctrine/Tests/DBAL/Schema/TableTest.php
+15
-0
No files found.
lib/Doctrine/DBAL/Schema/Index.php
View file @
2cb22496
...
@@ -76,6 +76,16 @@ class Index extends AbstractAsset implements Constraint
...
@@ -76,6 +76,16 @@ class Index extends AbstractAsset implements Constraint
{
{
return
$this
->
_columns
;
return
$this
->
_columns
;
}
}
/**
* Is the index neither unique nor primary key?
*
* @return bool
*/
public
function
isSimpleIndex
()
{
return
!
$this
->
_isPrimary
&&
!
$this
->
_isUnique
;
}
/**
/**
* @return bool
* @return bool
...
@@ -164,7 +174,9 @@ class Index extends AbstractAsset implements Constraint
...
@@ -164,7 +174,9 @@ class Index extends AbstractAsset implements Constraint
*/
*/
public
function
overrules
(
Index
$other
)
public
function
overrules
(
Index
$other
)
{
{
if
(
$other
->
isPrimary
()
||
$other
->
isUnique
())
{
if
(
$other
->
isPrimary
())
{
return
false
;
}
else
if
(
$this
->
isSimpleIndex
()
&&
$other
->
isUnique
())
{
return
false
;
return
false
;
}
}
...
...
tests/Doctrine/Tests/DBAL/Schema/TableTest.php
View file @
2cb22496
...
@@ -406,6 +406,21 @@ class TableTest extends \PHPUnit_Framework_TestCase
...
@@ -406,6 +406,21 @@ class TableTest extends \PHPUnit_Framework_TestCase
$this
->
assertEquals
(
1
,
count
(
$table
->
getIndexes
()));
$this
->
assertEquals
(
1
,
count
(
$table
->
getIndexes
()));
$this
->
assertFalse
(
$table
->
hasIndex
(
$index
->
getName
()));
$this
->
assertFalse
(
$table
->
hasIndex
(
$index
->
getName
()));
}
}
public
function
testPrimaryKeyOverrulesUniqueIndex
()
{
$table
=
new
Table
(
"bar"
);
$table
->
addColumn
(
'baz'
,
'integer'
,
array
());
$table
->
addUniqueIndex
(
array
(
'baz'
));
$table
->
setPrimaryKey
(
array
(
'baz'
));
$indexes
=
$table
->
getIndexes
();
$this
->
assertEquals
(
1
,
count
(
$indexes
),
"Table should only contain the primary key table index, not the unique one anymore, because it was overruled."
);
$index
=
current
(
$indexes
);
$this
->
assertTrue
(
$index
->
isPrimary
());
}
/**
/**
* @group DBAL-64
* @group DBAL-64
...
...
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