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
7f7a425c
Commit
7f7a425c
authored
Apr 01, 2013
by
Benjamin Eberlei
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'DBAL-435'
parents
89c3e54c
512f0018
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
28 additions
and
15 deletions
+28
-15
SQLParserUtils.php
lib/Doctrine/DBAL/SQLParserUtils.php
+6
-4
DataAccessTest.php
tests/Doctrine/Tests/DBAL/Functional/DataAccessTest.php
+12
-0
SQLParserUtilsTest.php
tests/Doctrine/Tests/DBAL/SQLParserUtilsTest.php
+10
-11
No files found.
lib/Doctrine/DBAL/SQLParserUtils.php
View file @
7f7a425c
...
@@ -130,11 +130,13 @@ class SQLParserUtils
...
@@ -130,11 +130,13 @@ class SQLParserUtils
$types
=
array_merge
(
$types
=
array_merge
(
array_slice
(
$types
,
0
,
$needle
),
array_slice
(
$types
,
0
,
$needle
),
array_fill
(
0
,
$count
,
$types
[
$needle
]
-
Connection
::
ARRAY_PARAM_OFFSET
),
// array needles are at PDO::PARAM_* + 100
$count
?
array_fill
(
0
,
$count
,
$types
[
$needle
]
-
Connection
::
ARRAY_PARAM_OFFSET
)
:
// array needles are at PDO::PARAM_* + 100
array
(),
array_slice
(
$types
,
$needle
+
1
)
array_slice
(
$types
,
$needle
+
1
)
);
);
$expandStr
=
implode
(
", "
,
array_fill
(
0
,
$count
,
"?"
))
;
$expandStr
=
$count
?
implode
(
", "
,
array_fill
(
0
,
$count
,
"?"
))
:
'NULL'
;
$query
=
substr
(
$query
,
0
,
$needlePos
)
.
$expandStr
.
substr
(
$query
,
$needlePos
+
1
);
$query
=
substr
(
$query
,
0
,
$needlePos
)
.
$expandStr
.
substr
(
$query
,
$needlePos
+
1
);
$paramOffset
+=
(
$count
-
1
);
// Grows larger by number of parameters minus the replaced needle.
$paramOffset
+=
(
$count
-
1
);
// Grows larger by number of parameters minus the replaced needle.
...
@@ -164,7 +166,7 @@ class SQLParserUtils
...
@@ -164,7 +166,7 @@ class SQLParserUtils
}
}
$count
=
count
(
$value
);
$count
=
count
(
$value
);
$expandStr
=
$count
>
0
?
implode
(
', '
,
array_fill
(
0
,
$count
,
'?'
))
:
'
?
'
;
$expandStr
=
$count
>
0
?
implode
(
', '
,
array_fill
(
0
,
$count
,
'?'
))
:
'
NULL
'
;
foreach
(
$value
as
$val
)
{
foreach
(
$value
as
$val
)
{
$paramsOrd
[]
=
$val
;
$paramsOrd
[]
=
$val
;
...
@@ -197,4 +199,4 @@ class SQLParserUtils
...
@@ -197,4 +199,4 @@ class SQLParserUtils
return
$fragments
[
1
];
return
$fragments
[
1
];
}
}
}
}
\ No newline at end of file
tests/Doctrine/Tests/DBAL/Functional/DataAccessTest.php
View file @
7f7a425c
...
@@ -548,6 +548,18 @@ class DataAccessTest extends \Doctrine\Tests\DbalFunctionalTestCase
...
@@ -548,6 +548,18 @@ class DataAccessTest extends \Doctrine\Tests\DbalFunctionalTestCase
}
}
}
}
/**
* @group DBAL-435
*/
public
function
testEmptyParameters
()
{
$sql
=
"SELECT * FROM fetch_table WHERE test_int IN (?)"
;
$stmt
=
$this
->
_conn
->
executeQuery
(
$sql
,
array
(
array
()),
array
(
\Doctrine\DBAL\Connection
::
PARAM_INT_ARRAY
));
$rows
=
$stmt
->
fetchAll
();
$this
->
assertEquals
(
array
(),
$rows
);
}
private
function
setupFixture
()
private
function
setupFixture
()
{
{
$this
->
_conn
->
executeQuery
(
'DELETE FROM fetch_table'
)
->
execute
();
$this
->
_conn
->
executeQuery
(
'DELETE FROM fetch_table'
)
->
execute
();
...
...
tests/Doctrine/Tests/DBAL/SQLParserUtilsTest.php
View file @
7f7a425c
...
@@ -108,21 +108,21 @@ SQLDATA
...
@@ -108,21 +108,21 @@ SQLDATA
array
(
1
,
2
,
3
,
4
,
5
),
array
(
1
,
2
,
3
,
4
,
5
),
array
(
\PDO
::
PARAM_INT
,
\PDO
::
PARAM_INT
,
\PDO
::
PARAM_INT
,
\PDO
::
PARAM_INT
,
\PDO
::
PARAM_INT
)
array
(
\PDO
::
PARAM_INT
,
\PDO
::
PARAM_INT
,
\PDO
::
PARAM_INT
,
\PDO
::
PARAM_INT
,
\PDO
::
PARAM_INT
)
),
),
//
Positional
: Empty "integer" array DDC-1978
//
Positional
: Empty "integer" array DDC-1978
array
(
array
(
"SELECT * FROM Foo WHERE foo IN (?)"
,
"SELECT * FROM Foo WHERE foo IN (?)"
,
array
(
'foo'
=>
array
()),
array
(
array
()),
array
(
'foo'
=>
Connection
::
PARAM_INT_ARRAY
),
array
(
Connection
::
PARAM_INT_ARRAY
),
'SELECT * FROM Foo WHERE foo IN (
?
)'
,
'SELECT * FROM Foo WHERE foo IN (
NULL
)'
,
array
(),
array
(),
array
()
array
()
),
),
//
Positional
: Empty "str" array DDC-1978
//
Positional
: Empty "str" array DDC-1978
array
(
array
(
"SELECT * FROM Foo WHERE foo IN (?)"
,
"SELECT * FROM Foo WHERE foo IN (?)"
,
array
(
'foo'
=>
array
()),
array
(
array
()),
array
(
'foo'
=>
Connection
::
PARAM_STR_ARRAY
),
array
(
Connection
::
PARAM_STR_ARRAY
),
'SELECT * FROM Foo WHERE foo IN (
?
)'
,
'SELECT * FROM Foo WHERE foo IN (
NULL
)'
,
array
(),
array
(),
array
()
array
()
),
),
...
@@ -145,7 +145,6 @@ SQLDATA
...
@@ -145,7 +145,6 @@ SQLDATA
array
(
1
,
'Some String'
),
array
(
1
,
'Some String'
),
array
(
\PDO
::
PARAM_INT
,
\PDO
::
PARAM_STR
)
array
(
\PDO
::
PARAM_INT
,
\PDO
::
PARAM_STR
)
),
),
// Named parameters : Very simple with one needle
// Named parameters : Very simple with one needle
array
(
array
(
"SELECT * FROM Foo WHERE foo IN (:foo)"
,
"SELECT * FROM Foo WHERE foo IN (:foo)"
,
...
@@ -224,7 +223,7 @@ SQLDATA
...
@@ -224,7 +223,7 @@ SQLDATA
"SELECT * FROM Foo WHERE foo IN (:foo)"
,
"SELECT * FROM Foo WHERE foo IN (:foo)"
,
array
(
'foo'
=>
array
()),
array
(
'foo'
=>
array
()),
array
(
'foo'
=>
Connection
::
PARAM_INT_ARRAY
),
array
(
'foo'
=>
Connection
::
PARAM_INT_ARRAY
),
'SELECT * FROM Foo WHERE foo IN (
?
)'
,
'SELECT * FROM Foo WHERE foo IN (
NULL
)'
,
array
(),
array
(),
array
()
array
()
),
),
...
@@ -233,7 +232,7 @@ SQLDATA
...
@@ -233,7 +232,7 @@ SQLDATA
"SELECT * FROM Foo WHERE foo IN (:foo) OR bar IN (:bar)"
,
"SELECT * FROM Foo WHERE foo IN (:foo) OR bar IN (:bar)"
,
array
(
'foo'
=>
array
(),
'bar'
=>
array
()),
array
(
'foo'
=>
array
(),
'bar'
=>
array
()),
array
(
'foo'
=>
Connection
::
PARAM_STR_ARRAY
,
'bar'
=>
Connection
::
PARAM_STR_ARRAY
),
array
(
'foo'
=>
Connection
::
PARAM_STR_ARRAY
,
'bar'
=>
Connection
::
PARAM_STR_ARRAY
),
'SELECT * FROM Foo WHERE foo IN (
?) OR bar IN (?
)'
,
'SELECT * FROM Foo WHERE foo IN (
NULL) OR bar IN (NULL
)'
,
array
(),
array
(),
array
()
array
()
),
),
...
...
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