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
854fa9b4
Commit
854fa9b4
authored
Apr 08, 2013
by
Steve Müller
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
adjust platforms to make use of quoted index and constraint column names
parent
46271a9a
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
18 additions
and
29 deletions
+18
-29
AbstractPlatform.php
lib/Doctrine/DBAL/Platforms/AbstractPlatform.php
+15
-22
MySqlPlatform.php
lib/Doctrine/DBAL/Platforms/MySqlPlatform.php
+1
-2
SQLServerPlatform.php
lib/Doctrine/DBAL/Platforms/SQLServerPlatform.php
+2
-5
No files found.
lib/Doctrine/DBAL/Platforms/AbstractPlatform.php
View file @
854fa9b4
...
...
@@ -1166,9 +1166,7 @@ abstract class AbstractPlatform
/* @var $index Index */
if
(
$index
->
isPrimary
())
{
$platform
=
$this
;
$options
[
'primary'
]
=
array_map
(
function
(
$columnName
)
use
(
$table
,
$platform
)
{
return
$table
->
getColumn
(
$columnName
)
->
getQuotedName
(
$platform
);
},
$index
->
getColumns
());
$options
[
'primary'
]
=
$index
->
getQuotedColumns
(
$this
);
$options
[
'primary_index'
]
=
$index
;
}
else
{
$options
[
'indexes'
][
$index
->
getName
()]
=
$index
;
...
...
@@ -1337,11 +1335,7 @@ abstract class AbstractPlatform
$query
=
'ALTER TABLE '
.
$table
.
' ADD CONSTRAINT '
.
$constraint
->
getQuotedName
(
$this
);
$columns
=
array
();
foreach
(
$constraint
->
getColumns
()
as
$column
)
{
$columns
[]
=
$column
;
}
$columnList
=
'('
.
implode
(
', '
,
$columns
)
.
')'
;
$columnList
=
'('
.
implode
(
', '
,
$constraint
->
getQuotedColumns
(
$this
))
.
')'
;
$referencesClause
=
''
;
if
(
$constraint
instanceof
Index
)
{
...
...
@@ -1357,13 +1351,8 @@ abstract class AbstractPlatform
}
else
if
(
$constraint
instanceof
ForeignKeyConstraint
)
{
$query
.=
' FOREIGN KEY'
;
$foreignColumns
=
array
();
foreach
(
$constraint
->
getForeignColumns
()
as
$column
)
{
$foreignColumns
[]
=
$column
;
}
$referencesClause
=
' REFERENCES '
.
$constraint
->
getQuotedForeignTableName
(
$this
)
.
' ('
.
implode
(
', '
,
$
foreignColumns
)
.
')'
;
' ('
.
implode
(
', '
,
$
constraint
->
getQuotedForeignColumns
(
$this
)
)
.
')'
;
}
$query
.=
' '
.
$columnList
.
$referencesClause
;
...
...
@@ -1384,7 +1373,7 @@ abstract class AbstractPlatform
$table
=
$table
->
getQuotedName
(
$this
);
}
$name
=
$index
->
getQuotedName
(
$this
);
$columns
=
$index
->
get
Columns
(
);
$columns
=
$index
->
get
QuotedColumns
(
$this
);
if
(
count
(
$columns
)
==
0
)
{
throw
new
\InvalidArgumentException
(
"Incomplete definition. 'columns' required."
);
...
...
@@ -1422,7 +1411,7 @@ abstract class AbstractPlatform
*/
public
function
getCreatePrimaryKeySQL
(
Index
$index
,
$table
)
{
return
'ALTER TABLE '
.
$table
.
' ADD PRIMARY KEY ('
.
$this
->
getIndexFieldDeclarationListSQL
(
$index
->
get
Columns
(
))
.
')'
;
return
'ALTER TABLE '
.
$table
.
' ADD PRIMARY KEY ('
.
$this
->
getIndexFieldDeclarationListSQL
(
$index
->
get
QuotedColumns
(
$this
))
.
')'
;
}
/**
...
...
@@ -1874,12 +1863,14 @@ abstract class AbstractPlatform
*/
public
function
getUniqueConstraintDeclarationSQL
(
$name
,
Index
$index
)
{
if
(
count
(
$index
->
getColumns
())
===
0
)
{
$columns
=
$index
->
getQuotedColumns
(
$this
);
if
(
count
(
$columns
)
===
0
)
{
throw
new
\InvalidArgumentException
(
"Incomplete definition. 'columns' required."
);
}
return
'CONSTRAINT '
.
$name
.
' UNIQUE ('
.
$this
->
getIndexFieldDeclarationListSQL
(
$
index
->
getColumns
()
)
.
$this
->
getIndexFieldDeclarationListSQL
(
$
columns
)
.
')'
;
}
...
...
@@ -1894,12 +1885,14 @@ abstract class AbstractPlatform
*/
public
function
getIndexDeclarationSQL
(
$name
,
Index
$index
)
{
if
(
count
(
$index
->
getColumns
())
===
0
)
{
$columns
=
$index
->
getQuotedColumns
(
$this
);
if
(
count
(
$columns
)
===
0
)
{
throw
new
\InvalidArgumentException
(
"Incomplete definition. 'columns' required."
);
}
return
$this
->
getCreateIndexSQLFlags
(
$index
)
.
'INDEX '
.
$name
.
' ('
.
$this
->
getIndexFieldDeclarationListSQL
(
$
index
->
getColumns
()
)
.
$this
->
getIndexFieldDeclarationListSQL
(
$
columns
)
.
')'
;
}
...
...
@@ -2061,10 +2054,10 @@ abstract class AbstractPlatform
throw
new
\InvalidArgumentException
(
"Incomplete definition. 'foreignTable' required."
);
}
$sql
.=
implode
(
', '
,
$foreignKey
->
get
LocalColumns
(
))
$sql
.=
implode
(
', '
,
$foreignKey
->
get
QuotedLocalColumns
(
$this
))
.
') REFERENCES '
.
$foreignKey
->
getQuotedForeignTableName
(
$this
)
.
' ('
.
implode
(
', '
,
$foreignKey
->
get
ForeignColumns
(
))
.
')'
;
.
implode
(
', '
,
$foreignKey
->
get
QuotedForeignColumns
(
$this
))
.
')'
;
return
$sql
;
}
...
...
lib/Doctrine/DBAL/Platforms/MySqlPlatform.php
View file @
854fa9b4
...
...
@@ -562,7 +562,6 @@ class MySqlPlatform extends AbstractPlatform
foreach
(
$diff
->
addedIndexes
as
$addKey
=>
$addIndex
)
{
if
(
$remIndex
->
getColumns
()
==
$addIndex
->
getColumns
())
{
$columns
=
$addIndex
->
getColumns
();
$type
=
''
;
if
(
$addIndex
->
isUnique
())
{
$type
=
'UNIQUE '
;
...
...
@@ -570,7 +569,7 @@ class MySqlPlatform extends AbstractPlatform
$query
=
'ALTER TABLE '
.
$table
.
' DROP INDEX '
.
$remIndex
->
getName
()
.
', '
;
$query
.=
'ADD '
.
$type
.
'INDEX '
.
$addIndex
->
getName
();
$query
.=
' ('
.
$this
->
getIndexFieldDeclarationListSQL
(
$
columns
)
.
')'
;
$query
.=
' ('
.
$this
->
getIndexFieldDeclarationListSQL
(
$
addIndex
->
getQuotedColumns
(
$this
)
)
.
')'
;
$sql
[]
=
$query
;
...
...
lib/Doctrine/DBAL/Platforms/SQLServerPlatform.php
View file @
854fa9b4
...
...
@@ -262,7 +262,7 @@ class SQLServerPlatform extends AbstractPlatform
if
(
$index
->
hasFlag
(
'nonclustered'
))
{
$flags
=
' NONCLUSTERED'
;
}
return
'ALTER TABLE '
.
$table
.
' ADD PRIMARY KEY'
.
$flags
.
' ('
.
$this
->
getIndexFieldDeclarationListSQL
(
$index
->
get
Columns
(
))
.
')'
;
return
'ALTER TABLE '
.
$table
.
' ADD PRIMARY KEY'
.
$flags
.
' ('
.
$this
->
getIndexFieldDeclarationListSQL
(
$index
->
get
QuotedColumns
(
$this
))
.
')'
;
}
/**
...
...
@@ -344,11 +344,8 @@ class SQLServerPlatform extends AbstractPlatform
private
function
_appendUniqueConstraintDefinition
(
$sql
,
Index
$index
)
{
$fields
=
array
();
foreach
(
$index
->
getColumns
()
as
$field
=>
$definition
)
{
if
(
!
is_array
(
$definition
))
{
$field
=
$definition
;
}
foreach
(
$index
->
getQuotedColumns
(
$this
)
as
$field
)
{
$fields
[]
=
$field
.
' IS NOT NULL'
;
}
...
...
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