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
db36902a
Commit
db36902a
authored
Mar 31, 2014
by
Steve Müller
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix TRIM expression
parent
7c68e80f
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
20 additions
and
11 deletions
+20
-11
AbstractPlatform.php
lib/Doctrine/DBAL/Platforms/AbstractPlatform.php
+13
-6
SQLAnywherePlatform.php
lib/Doctrine/DBAL/Platforms/SQLAnywherePlatform.php
+1
-1
SQLAnywherePlatformTest.php
...Doctrine/Tests/DBAL/Platforms/SQLAnywherePlatformTest.php
+6
-4
No files found.
lib/Doctrine/DBAL/Platforms/AbstractPlatform.php
View file @
db36902a
...
...
@@ -724,24 +724,31 @@ abstract class AbstractPlatform
*/
public
function
getTrimExpression
(
$str
,
$pos
=
self
::
TRIM_UNSPECIFIED
,
$char
=
false
)
{
$posStr
=
''
;
$trimChar
=
(
$char
!=
false
)
?
$char
.
' FROM '
:
''
;
$expression
=
''
;
switch
(
$pos
)
{
case
self
::
TRIM_LEADING
:
$
posStr
=
'LEADING '
.
$trimChar
;
$
expression
=
'LEADING '
;
break
;
case
self
::
TRIM_TRAILING
:
$
posStr
=
'TRAILING '
.
$trimChar
;
$
expression
=
'TRAILING '
;
break
;
case
self
::
TRIM_BOTH
:
$
posStr
=
'BOTH '
.
$trimChar
;
$
expression
=
'BOTH '
;
break
;
}
return
'TRIM('
.
$posStr
.
$str
.
')'
;
if
(
false
!==
$char
)
{
$expression
.=
$char
.
' '
;
}
if
(
$pos
||
false
!==
$char
)
{
$expression
.=
'FROM '
;
}
return
'TRIM('
.
$expression
.
$str
.
')'
;
}
/**
...
...
lib/Doctrine/DBAL/Platforms/SQLAnywherePlatform.php
View file @
db36902a
...
...
@@ -1128,7 +1128,7 @@ class SQLAnywherePlatform extends AbstractPlatform
}
}
$pattern
=
"'%[^
$char
]%'"
;
$pattern
=
"'%[^
' +
$char
+ '
]%'"
;
switch
(
$pos
)
{
case
self
::
TRIM_LEADING
:
...
...
tests/Doctrine/Tests/DBAL/Platforms/SQLAnywherePlatformTest.php
View file @
db36902a
...
...
@@ -568,19 +568,21 @@ class SQLAnywherePlatformTest extends AbstractPlatformTestCase
$this
->
_platform
->
getTrimExpression
(
'column'
,
AbstractPlatform
::
TRIM_UNSPECIFIED
)
);
$this
->
assertEquals
(
"SUBSTR(column, PATINDEX('%[^
c
]%', column))"
,
"SUBSTR(column, PATINDEX('%[^
' + c + '
]%', column))"
,
$this
->
_platform
->
getTrimExpression
(
'column'
,
AbstractPlatform
::
TRIM_LEADING
,
'c'
)
);
$this
->
assertEquals
(
"REVERSE(SUBSTR(REVERSE(column), PATINDEX('%[^
c
]%', REVERSE(column))))"
,
"REVERSE(SUBSTR(REVERSE(column), PATINDEX('%[^
' + c + '
]%', REVERSE(column))))"
,
$this
->
_platform
->
getTrimExpression
(
'column'
,
AbstractPlatform
::
TRIM_TRAILING
,
'c'
)
);
$this
->
assertEquals
(
"REVERSE(SUBSTR(REVERSE(SUBSTR(column, PATINDEX('%[^c]%', column))), PATINDEX('%[^c]%', REVERSE(SUBSTR(column, PATINDEX('%[^c]%', column))))))"
,
"REVERSE(SUBSTR(REVERSE(SUBSTR(column, PATINDEX('%[^' + c + ']%', column))), PATINDEX('%[^' + c + ']%', "
.
"REVERSE(SUBSTR(column, PATINDEX('%[^' + c + ']%', column))))))"
,
$this
->
_platform
->
getTrimExpression
(
'column'
,
null
,
'c'
)
);
$this
->
assertEquals
(
"REVERSE(SUBSTR(REVERSE(SUBSTR(column, PATINDEX('%[^c]%', column))), PATINDEX('%[^c]%', REVERSE(SUBSTR(column, PATINDEX('%[^c]%', column))))))"
,
"REVERSE(SUBSTR(REVERSE(SUBSTR(column, PATINDEX('%[^' + c + ']%', column))), PATINDEX('%[^' + c + ']%', "
.
"REVERSE(SUBSTR(column, PATINDEX('%[^' + c + ']%', column))))))"
,
$this
->
_platform
->
getTrimExpression
(
'column'
,
AbstractPlatform
::
TRIM_UNSPECIFIED
,
'c'
)
);
}
...
...
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