Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
D
drupal
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Locked Files
Custom Issue Tracker
Custom Issue Tracker
Labels
Merge Requests
316
Merge Requests
316
Requirements
Requirements
List
Security & Compliance
Security & Compliance
Dependency List
License Compliance
Analytics
Analytics
Code Review
Insights
Issue
Repository
Value Stream
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Commits
Open sidebar
project
drupal
Commits
19a7f811
Commit
19a7f811
authored
May 09, 2015
by
alexpott
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Issue
#2475247
by amateescu, dawehner: SQLite: Fix views\Tests\Handler\FilterStringTest
parent
30063228
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
20 additions
and
17 deletions
+20
-17
core/lib/Drupal/Core/Database/Driver/sqlite/Statement.php
core/lib/Drupal/Core/Database/Driver/sqlite/Statement.php
+2
-8
core/modules/system/src/Tests/Database/QueryTest.php
core/modules/system/src/Tests/Database/QueryTest.php
+0
-6
core/modules/views/src/Plugin/views/filter/StringFilter.php
core/modules/views/src/Plugin/views/filter/StringFilter.php
+6
-2
core/modules/views/views.module
core/modules/views/views.module
+12
-1
No files found.
core/lib/Drupal/Core/Database/Driver/sqlite/Statement.php
View file @
19a7f811
...
...
@@ -39,10 +39,7 @@ protected function getStatement($query, &$args = array()) {
$count
=
0
;
$new_args
=
array
();
foreach
(
$args
as
$value
)
{
// Integers expressed as strings (e.g. '5') have to treated as numeric
// values. Sadly, PHP has an upper limit on integers, PHP_INT_MAX, so
// we can not support numbers higher than that.
if
(
is_float
(
$value
)
||
is_int
(
$value
)
||
(
is_numeric
(
$value
)
&&
$value
<=
PHP_INT_MAX
))
{
if
(
is_float
(
$value
)
||
is_int
(
$value
))
{
if
(
is_float
(
$value
))
{
// Force the conversion to float so as not to loose precision
// in the automatic cast.
...
...
@@ -61,10 +58,7 @@ protected function getStatement($query, &$args = array()) {
else
{
// Else, this is using named placeholders.
foreach
(
$args
as
$placeholder
=>
$value
)
{
// Integers expressed as strings (e.g. '5') have to treated as numeric
// values. Sadly, PHP has an upper limit on integers, PHP_INT_MAX, so
// we can not support numbers higher than that.
if
(
is_float
(
$value
)
||
is_int
(
$value
)
||
(
is_numeric
(
$value
)
&&
$value
<=
PHP_INT_MAX
))
{
if
(
is_float
(
$value
)
||
is_int
(
$value
))
{
if
(
is_float
(
$value
))
{
// Force the conversion to float so as not to loose precision
// in the automatic cast.
...
...
core/modules/system/src/Tests/Database/QueryTest.php
View file @
19a7f811
...
...
@@ -80,12 +80,6 @@ public function testNumericExpressionSubstitution() {
':count'
=>
3
,
))
->
fetchField
();
$this
->
assertEqual
((
bool
)
$count
,
TRUE
);
// Test that numeric arguments expressed as strings also work properly.
$count
=
db_query
(
'SELECT COUNT(*) >= :count FROM {test}'
,
array
(
':count'
=>
(
string
)
3
,
))
->
fetchField
();
$this
->
assertEqual
((
bool
)
$count
,
TRUE
);
}
}
core/modules/views/src/Plugin/views/filter/StringFilter.php
View file @
19a7f811
...
...
@@ -320,12 +320,16 @@ protected function opNotLike($field) {
protected
function
opShorterThan
(
$field
)
{
$placeholder
=
$this
->
placeholder
();
$this
->
query
->
addWhereExpression
(
$this
->
options
[
'group'
],
"LENGTH(
$field
) <
$placeholder
"
,
array
(
$placeholder
=>
$this
->
value
));
// Type cast the argument to an integer because the SQLite database driver
// has to do some specific alterations to the query base on that data type.
$this
->
query
->
addWhereExpression
(
$this
->
options
[
'group'
],
"LENGTH(
$field
) <
$placeholder
"
,
array
(
$placeholder
=>
(
int
)
$this
->
value
));
}
protected
function
opLongerThan
(
$field
)
{
$placeholder
=
$this
->
placeholder
();
$this
->
query
->
addWhereExpression
(
$this
->
options
[
'group'
],
"LENGTH(
$field
) >
$placeholder
"
,
array
(
$placeholder
=>
$this
->
value
));
// Type cast the argument to an integer because the SQLite database driver
// has to do some specific alterations to the query base on that data type.
$this
->
query
->
addWhereExpression
(
$this
->
options
[
'group'
],
"LENGTH(
$field
) >
$placeholder
"
,
array
(
$placeholder
=>
(
int
)
$this
->
value
));
}
/**
...
...
core/modules/views/views.module
View file @
19a7f811
...
...
@@ -745,7 +745,18 @@ function _views_query_tag_alter_condition(AlterableInterface $query, &$condition
views_query_views_alter
(
$condition
[
'value'
]);
}
elseif
(
isset
(
$condition
[
'value'
]))
{
$condition
[
'value'
]
=
str_replace
(
array_keys
(
$substitutions
),
array_values
(
$substitutions
),
$condition
[
'value'
]);
// We can not use a simple str_replace() here because it always returns
// a string and we have to keep the type of the condition value intact.
if
(
is_array
(
$condition
[
'value'
]))
{
foreach
(
$condition
[
'value'
]
as
&
$value
)
{
if
(
is_string
(
$value
))
{
$value
=
str_replace
(
array_keys
(
$substitutions
),
array_values
(
$substitutions
),
$value
);
}
}
}
elseif
(
is_string
(
$condition
[
'value'
]))
{
$condition
[
'value'
]
=
str_replace
(
array_keys
(
$substitutions
),
array_values
(
$substitutions
),
$condition
[
'value'
]);
}
}
}
}
...
...
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