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
6197492f
Commit
6197492f
authored
Nov 17, 2010
by
Juozas Kaziukenas
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fixed unique key constraints
parent
63e121f3
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
55 additions
and
0 deletions
+55
-0
MsSqlPlatform.php
lib/Doctrine/DBAL/Platforms/MsSqlPlatform.php
+55
-0
No files found.
lib/Doctrine/DBAL/Platforms/MsSqlPlatform.php
View file @
6197492f
...
...
@@ -179,6 +179,14 @@ class MsSqlPlatform extends AbstractPlatform
*/
protected
function
_getCreateTableSQL
(
$tableName
,
array
$columns
,
array
$options
=
array
())
{
// @todo does other code breaks because of this?
// foce primary keys to be not null
foreach
(
$columns
as
&
$column
)
{
if
(
isset
(
$column
[
'primary'
])
&&
$column
[
'primary'
])
{
$column
[
'notnull'
]
=
true
;
}
}
$columnListSql
=
$this
->
getColumnDeclarationListSQL
(
$columns
);
if
(
isset
(
$options
[
'uniqueConstraints'
])
&&
!
empty
(
$options
[
'uniqueConstraints'
]))
{
...
...
@@ -215,6 +223,53 @@ class MsSqlPlatform extends AbstractPlatform
return
$sql
;
}
/**
* @override
*/
public
function
getUniqueConstraintDeclarationSQL
(
$name
,
Index
$index
)
{
$constraint
=
parent
::
getUniqueConstraintDeclarationSQL
(
$name
,
$index
);
$constraint
=
$this
->
_appendUniqueConstraintDefinition
(
$constraint
,
$index
);
return
$constraint
;
}
/**
* @override
*/
public
function
getCreateIndexSQL
(
Index
$index
,
$table
)
{
$constraint
=
parent
::
getCreateIndexSQL
(
$index
,
$table
);
if
(
$index
->
isUnique
())
{
$constraint
=
$this
->
_appendUniqueConstraintDefinition
(
$constraint
,
$index
);
}
return
$constraint
;
}
/**
* Extend unique key constraint with required filters
*
* @param string $sql
* @param Index $index
* @return string
*/
private
function
_appendUniqueConstraintDefinition
(
$sql
,
Index
$index
)
{
$fields
=
array
();
foreach
(
$index
->
getColumns
()
as
$field
=>
$definition
)
{
if
(
!
is_array
(
$definition
))
{
$field
=
$definition
;
}
$fields
[]
=
$field
.
' IS NOT NULL'
;
}
return
$sql
.
' WHERE '
.
implode
(
' OR '
,
$fields
);
}
/**
* @override
...
...
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