Skip to content
GitLab
Menu
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
project
drupal
Commits
a269b9cc
Commit
a269b9cc
authored
Nov 13, 2008
by
Dries
Browse files
- Patch
#322458
by hswong3i: tests for queryRange().
parent
3a3c4827
Changes
4
Hide whitespace changes
Inline
Side-by-side
includes/database/database.inc
View file @
a269b9cc
...
...
@@ -683,7 +683,7 @@ public function startTransaction($required = FALSE) {
* A database query result resource, or NULL if the query was not executed
* correctly.
*/
abstract
public
function
queryRange
(
$query
,
Array
$args
,
$from
,
$count
,
Array
$options
);
abstract
public
function
queryRange
(
$query
,
Array
$args
,
$from
,
$count
,
Array
$options
=
array
()
);
/**
* Runs a SELECT query and stores its results in a temporary table.
...
...
includes/database/mysql/database.inc
View file @
a269b9cc
...
...
@@ -39,10 +39,7 @@ public function __construct(Array $connection_options = array()) {
$this
->
exec
(
'SET sql_mode=STRICT_ALL_TABLES'
);
}
public
function
queryRange
(
$query
,
Array
$args
,
$from
,
$count
,
Array
$options
)
{
// Backward compatibility hack, temporary.
$query
=
str_replace
(
array
(
'%d'
,
'%f'
,
'%b'
,
"'%s'"
),
'?'
,
$query
);
public
function
queryRange
(
$query
,
Array
$args
,
$from
,
$count
,
Array
$options
=
array
())
{
return
$this
->
query
(
$query
.
' LIMIT '
.
$from
.
', '
.
$count
,
$args
,
$options
);
}
...
...
includes/database/pgsql/database.inc
View file @
a269b9cc
...
...
@@ -75,10 +75,7 @@ public function query($query, Array $args = array(), $options = array()) {
}
}
public
function
queryRange
(
$query
,
Array
$args
,
$from
,
$count
,
Array
$options
)
{
// Backward compatibility hack, temporary.
$query
=
str_replace
(
array
(
'%d'
,
'%f'
,
'%b'
,
"'%s'"
),
'?'
,
$query
);
public
function
queryRange
(
$query
,
Array
$args
,
$from
,
$count
,
Array
$options
=
array
())
{
return
$this
->
query
(
$query
.
' LIMIT '
.
$count
.
' OFFSET '
.
$from
,
$args
,
$options
);
}
...
...
modules/simpletest/tests/database_test.test
View file @
a269b9cc
...
...
@@ -1924,6 +1924,44 @@ class DatabaseLoggingTestCase extends DatabaseTestCase {
}
}
/**
* Range query tests.
*/
class
DatabaseRangeQueryTestCase
extends
DrupalWebTestCase
{
/**
* Define metadata for this test subclass.
*/
function
getInfo
()
{
return
array
(
'name'
=>
t
(
'Range query test'
),
'description'
=>
t
(
'Test the Range query functionality.'
),
'group'
=>
t
(
'Database'
),
);
}
/**
* Implementation of setUp().
*/
function
setUp
()
{
parent
::
setUp
(
'database_test'
);
}
/**
* Confirm that range query work and return correct result.
*/
function
testRangeQuery
()
{
// Test if return correct number of rows.
$range_rows
=
db_query_range
(
"SELECT name FROM
{
system
}
ORDER BY name"
,
array
(),
2
,
3
)
->
fetchAll
();
$this
->
assertEqual
(
count
(
$range_rows
),
3
,
t
(
'Range query work and return correct number of rows.'
));
// Test if return target data.
$raw_rows
=
db_query
(
"SELECT name FROM
{
system
}
ORDER BY name"
)
->
fetchAll
();
$raw_rows
=
array_slice
(
$raw_rows
,
2
,
3
);
$this
->
assertEqual
(
$range_rows
,
$raw_rows
,
t
(
'Range query work and return target data.'
));
}
}
/**
* Temporary query tests.
*/
...
...
Write
Preview
Supports
Markdown
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