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
46271a9a
Commit
46271a9a
authored
Apr 08, 2013
by
Steve Müller
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
adjust Index asset to be able to return quoted column names
parent
f042fd8b
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
34 additions
and
6 deletions
+34
-6
Index.php
lib/Doctrine/DBAL/Schema/Index.php
+34
-6
No files found.
lib/Doctrine/DBAL/Schema/Index.php
View file @
46271a9a
...
...
@@ -19,12 +19,15 @@
namespace
Doctrine\DBAL\Schema
;
use
Doctrine\DBAL\
Schema\Visitor\Visitor
;
use
Doctrine\DBAL\
Platforms\AbstractPlatform
;
class
Index
extends
AbstractAsset
implements
Constraint
{
/**
* @var array
* Asset identifier instances of the column names the index is associated with.
* array($columnName => Identifier)
*
* @var Identifier[]
*/
protected
$_columns
;
...
...
@@ -73,7 +76,7 @@ class Index extends AbstractAsset implements Constraint
protected
function
_addColumn
(
$column
)
{
if
(
is_string
(
$column
))
{
$this
->
_columns
[
]
=
$column
;
$this
->
_columns
[
$column
]
=
new
Identifier
(
$column
)
;
}
else
{
throw
new
\InvalidArgumentException
(
"Expecting a string as Index Column"
);
}
...
...
@@ -84,7 +87,30 @@ class Index extends AbstractAsset implements Constraint
*/
public
function
getColumns
()
{
return
$this
->
_columns
;
return
array_keys
(
$this
->
_columns
);
}
/**
* Returns the quoted representation of the column names
* the index is associated with.
*
* But only if they were defined with one or the column name
* is a keyword reserved by the platform.
* Otherwise the plain unquoted value as inserted is returned.
*
* @param \Doctrine\DBAL\Platforms\AbstractPlatform $platform The platform to use for quotation.
*
* @return array
*/
public
function
getQuotedColumns
(
AbstractPlatform
$platform
)
{
$columns
=
array
();
foreach
(
$this
->
_columns
as
$column
)
{
$columns
[]
=
$column
->
getQuotedName
(
$platform
);
}
return
$columns
;
}
/**
...
...
@@ -141,9 +167,11 @@ class Index extends AbstractAsset implements Constraint
*/
public
function
spansColumns
(
array
$columnNames
)
{
$columns
=
$this
->
getColumns
();
$numberOfColumns
=
count
(
$columns
);
$sameColumns
=
true
;
for
(
$i
=
0
;
$i
<
count
(
$this
->
_columns
)
;
$i
++
)
{
if
(
!
isset
(
$columnNames
[
$i
])
||
$this
->
trimQuotes
(
strtolower
(
$
this
->
_
columns
[
$i
]))
!=
$this
->
trimQuotes
(
strtolower
(
$columnNames
[
$i
])))
{
for
(
$i
=
0
;
$i
<
$numberOfColumns
;
$i
++
)
{
if
(
!
isset
(
$columnNames
[
$i
])
||
$this
->
trimQuotes
(
strtolower
(
$columns
[
$i
]))
!=
$this
->
trimQuotes
(
strtolower
(
$columnNames
[
$i
])))
{
$sameColumns
=
false
;
}
}
...
...
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