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
99f7a48d
Unverified
Commit
99f7a48d
authored
Oct 21, 2018
by
Sergei Morozov
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'bpo/2.8/#3277' into 2.8
parents
c02d1409
f4e2a0ec
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
12 additions
and
5 deletions
+12
-5
SQLParserUtils.php
lib/Doctrine/DBAL/SQLParserUtils.php
+8
-5
SQLParserUtilsTest.php
tests/Doctrine/Tests/DBAL/SQLParserUtilsTest.php
+4
-0
No files found.
lib/Doctrine/DBAL/SQLParserUtils.php
View file @
99f7a48d
...
@@ -31,6 +31,7 @@ use function is_int;
...
@@ -31,6 +31,7 @@ use function is_int;
use
function
key
;
use
function
key
;
use
function
ksort
;
use
function
ksort
;
use
function
preg_match_all
;
use
function
preg_match_all
;
use
function
sprintf
;
use
function
strlen
;
use
function
strlen
;
use
function
strpos
;
use
function
strpos
;
use
function
substr
;
use
function
substr
;
...
@@ -219,11 +220,13 @@ class SQLParserUtils
...
@@ -219,11 +220,13 @@ class SQLParserUtils
*/
*/
private
static
function
getUnquotedStatementFragments
(
$statement
)
private
static
function
getUnquotedStatementFragments
(
$statement
)
{
{
$literal
=
self
::
ESCAPED_SINGLE_QUOTED_TEXT
.
'|'
.
$literal
=
self
::
ESCAPED_SINGLE_QUOTED_TEXT
.
'|'
.
self
::
ESCAPED_DOUBLE_QUOTED_TEXT
.
'|'
.
self
::
ESCAPED_DOUBLE_QUOTED_TEXT
.
'|'
.
self
::
ESCAPED_BACKTICK_QUOTED_TEXT
.
'|'
.
self
::
ESCAPED_BACKTICK_QUOTED_TEXT
.
'|'
.
self
::
ESCAPED_BRACKET_QUOTED_TEXT
;
self
::
ESCAPED_BRACKET_QUOTED_TEXT
;
preg_match_all
(
"/([^'
\"
`\[]+)(?:
$literal
)?/s"
,
$statement
,
$fragments
,
PREG_OFFSET_CAPTURE
);
$expression
=
sprintf
(
'/((.+(?i:ARRAY)\\[.+\\])|([^\'"`\\[]+))(?:%s)?/s'
,
$literal
);
preg_match_all
(
$expression
,
$statement
,
$fragments
,
PREG_OFFSET_CAPTURE
);
return
$fragments
[
1
];
return
$fragments
[
1
];
}
}
...
...
tests/Doctrine/Tests/DBAL/SQLParserUtilsTest.php
View file @
99f7a48d
...
@@ -57,6 +57,10 @@ class SQLParserUtilsTest extends \Doctrine\Tests\DbalTestCase
...
@@ -57,6 +57,10 @@ class SQLParserUtilsTest extends \Doctrine\Tests\DbalTestCase
array
(
'SELECT [d.ns:col_name] FROM my_table d WHERE [d.date] >= :param1'
,
false
,
array
(
57
=>
'param1'
)),
// Ticket DBAL-552
array
(
'SELECT [d.ns:col_name] FROM my_table d WHERE [d.date] >= :param1'
,
false
,
array
(
57
=>
'param1'
)),
// Ticket DBAL-552
[
'SELECT * FROM foo WHERE jsonb_exists_any(foo.bar, ARRAY[:foo])'
,
false
,
[
56
=>
'foo'
]],
// Ticket GH-2295
[
'SELECT * FROM foo WHERE jsonb_exists_any(foo.bar, ARRAY[:foo])'
,
false
,
[
56
=>
'foo'
]],
// Ticket GH-2295
[
'SELECT * FROM foo WHERE jsonb_exists_any(foo.bar, array[:foo])'
,
false
,
[
56
=>
'foo'
]],
[
'SELECT * FROM foo WHERE jsonb_exists_any(foo.bar, array[:foo])'
,
false
,
[
56
=>
'foo'
]],
[
'SELECT table.field1, ARRAY[\'3\'] FROM schema.table table WHERE table.f1 = :foo AND ARRAY[\'3\']'
,
false
,
[
73
=>
'foo'
]],
[
'SELECT table.field1, ARRAY[\'3\']::integer[] FROM schema.table table WHERE table.f1 = :foo AND ARRAY[\'3\']::integer[]'
,
false
,
[
84
=>
'foo'
]],
[
'SELECT table.field1, ARRAY[:foo] FROM schema.table table WHERE table.f1 = :bar AND ARRAY[\'3\']'
,
false
,
[
27
=>
'foo'
,
74
=>
'bar'
]],
[
'SELECT table.field1, ARRAY[:foo]::integer[] FROM schema.table table WHERE table.f1 = :bar AND ARRAY[\'3\']::integer[]'
,
false
,
[
27
=>
'foo'
,
85
=>
'bar'
]],
array
(
array
(
<<<'SQLDATA'
<<<'SQLDATA'
SELECT * FROM foo WHERE
SELECT * FROM foo WHERE
...
...
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