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
de7b33d0
Unverified
Commit
de7b33d0
authored
Apr 19, 2019
by
Jonathan H. Wage
Committed by
Sergei Morozov
Nov 02, 2019
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #3519 from doctrine/fix-unique-constraint-with-empty-name
Fix UniqueConstraint with empty name.
parents
acb9d148
f3ce0292
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
37 additions
and
6 deletions
+37
-6
Table.php
lib/Doctrine/DBAL/Schema/Table.php
+1
-1
phpstan.neon.dist
phpstan.neon.dist
+0
-3
TableTest.php
tests/Doctrine/Tests/DBAL/Schema/TableTest.php
+36
-2
No files found.
lib/Doctrine/DBAL/Schema/Table.php
View file @
de7b33d0
...
...
@@ -865,7 +865,7 @@ class Table extends AbstractAsset
$name
=
strlen
(
$constraint
->
getName
())
?
$constraint
->
getName
()
:
$this
->
_generateIdentifierName
(
array_merge
((
array
)
$this
->
getName
(),
$constraint
->
get
Local
Columns
()),
array_merge
((
array
)
$this
->
getName
(),
$constraint
->
getColumns
()),
'fk'
,
$this
->
_getMaxIdentifierLength
()
);
...
...
phpstan.neon.dist
View file @
de7b33d0
...
...
@@ -56,9 +56,6 @@ parameters:
# weird class name, represented in stubs as OCI_(Lob|Collection)
- '~unknown class OCI-(Lob|Collection)~'
# https://github.com/doctrine/dbal/issues/3236
- '~^Call to an undefined method Doctrine\\DBAL\\Schema\\UniqueConstraint::getLocalColumns\(\)~'
# https://github.com/doctrine/dbal/issues/3237
- '~^Call to an undefined method Doctrine\\DBAL\\Driver\\PDOStatement::nextRowset\(\)~'
...
...
tests/Doctrine/Tests/DBAL/Schema/TableTest.php
View file @
de7b33d0
...
...
@@ -12,9 +12,10 @@ use Doctrine\DBAL\Schema\ForeignKeyConstraint;
use
Doctrine\DBAL\Schema\Index
;
use
Doctrine\DBAL\Schema\SchemaException
;
use
Doctrine\DBAL\Schema\Table
;
use
Doctrine\DBAL\Schema\UniqueConstraint
;
use
Doctrine\DBAL\Types\Type
;
use
Doctrine\Tests\DbalTestCase
;
use
function
array_
shift
;
use
function
array_
keys
;
use
function
current
;
class
TableTest
extends
DbalTestCase
...
...
@@ -206,7 +207,11 @@ class TableTest extends DbalTestCase
$constraints
=
$tableA
->
getForeignKeys
();
self
::
assertCount
(
1
,
$constraints
);
self
::
assertSame
(
$constraint
,
array_shift
(
$constraints
));
$constraintNames
=
array_keys
(
$constraints
);
self
::
assertSame
(
'fk_8c736521'
,
$constraintNames
[
0
]);
self
::
assertSame
(
$constraint
,
$constraints
[
'fk_8c736521'
]);
}
public
function
testOptions
()
:
void
...
...
@@ -896,4 +901,33 @@ class TableTest extends DbalTestCase
$table
->
setComment
(
'foo'
);
self
::
assertEquals
(
'foo'
,
$table
->
getComment
());
}
public
function
testUniqueConstraintWithEmptyName
()
:
void
{
$columns
=
[
new
Column
(
'column1'
,
Type
::
getType
(
Type
::
STRING
)),
new
Column
(
'column2'
,
Type
::
getType
(
Type
::
STRING
)),
new
Column
(
'column3'
,
Type
::
getType
(
Type
::
STRING
)),
new
Column
(
'column4'
,
Type
::
getType
(
Type
::
STRING
)),
];
$uniqueConstraints
=
[
new
UniqueConstraint
(
''
,
[
'column1'
,
'column2'
]),
new
UniqueConstraint
(
''
,
[
'column3'
,
'column4'
]),
];
$table
=
new
Table
(
'test'
,
$columns
,
[],
$uniqueConstraints
);
$constraints
=
$table
->
getUniqueConstraints
();
self
::
assertCount
(
2
,
$constraints
);
$constraintNames
=
array_keys
(
$constraints
);
self
::
assertSame
(
'fk_d87f7e0c341ce00bad15b1b1'
,
$constraintNames
[
0
]);
self
::
assertSame
(
'fk_d87f7e0cda12812744761484'
,
$constraintNames
[
1
]);
self
::
assertSame
(
$uniqueConstraints
[
0
],
$constraints
[
'fk_d87f7e0c341ce00bad15b1b1'
]);
self
::
assertSame
(
$uniqueConstraints
[
1
],
$constraints
[
'fk_d87f7e0cda12812744761484'
]);
}
}
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