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
800f2d9a
Commit
800f2d9a
authored
May 22, 2009
by
Dries
Browse files
- Patch
#467984
by Berdir: fixed some database glitches and extended the tests.
parent
092726df
Changes
2
Hide whitespace changes
Inline
Side-by-side
includes/database/select.inc
View file @
800f2d9a
...
...
@@ -461,7 +461,7 @@ public function havingArguments() {
}
public
function
having
(
$snippet
,
$args
=
array
())
{
$this
->
query
->
where
(
$snippet
,
$args
);
$this
->
query
->
having
(
$snippet
,
$args
);
return
$this
;
}
...
...
@@ -570,7 +570,8 @@ public function countQuery() {
// Also remove 'all_fields' statements, which are expanded into tablename.*
// when the query is executed.
foreach
(
$count
->
tables
as
$alias
=>
&
$table
)
{
$tables
=
&
$count
->
getTables
();
foreach
(
$tables
as
$alias
=>
&
$table
)
{
unset
(
$table
[
'all_fields'
]);
}
...
...
@@ -866,7 +867,7 @@ public function getArguments() {
$args
+=
$table
[
'arguments'
];
}
// If this table is a subquery, grab its arguments recursively.
if
(
$table
[
'table'
]
instanceof
SelectQuery
)
{
if
(
$table
[
'table'
]
instanceof
SelectQuery
Interface
)
{
$args
+=
$table
[
'table'
]
->
getArguments
();
}
}
...
...
@@ -985,7 +986,7 @@ public function rightJoin($table, $alias = NULL, $condition = NULL, $arguments =
public
function
addJoin
(
$type
,
$table
,
$alias
=
NULL
,
$condition
=
NULL
,
$arguments
=
array
())
{
if
(
empty
(
$alias
))
{
if
(
$table
instanceof
SelectQuery
)
{
if
(
$table
instanceof
SelectQuery
Interface
)
{
$alias
=
'subquery'
;
}
else
{
...
...
@@ -1089,7 +1090,7 @@ public function __toString() {
}
// If the table is a subquery, compile it and integrate it into this query.
if
(
$table
[
'table'
]
instanceof
SelectQuery
)
{
if
(
$table
[
'table'
]
instanceof
SelectQuery
Interface
)
{
$table_string
=
'('
.
(
string
)
$table
[
'table'
]
.
')'
;
}
else
{
...
...
modules/simpletest/tests/database_test.test
View file @
800f2d9a
...
...
@@ -1689,6 +1689,46 @@ class DatabaseSelectPagerDefaultTestCase extends DatabaseTestCase {
$this
->
assertEqual
(
count
(
$data
->
names
),
$correct_number
,
t
(
'Correct number of records returned by pager: @number'
,
array
(
'@number'
=>
$correct_number
)));
}
}
/**
* Confirm that a pager query with inner pager query returns valid results.
*
* This is a regression test for #467984.
*/
function
testInnerPagerQuery
()
{
$query
=
db_select
(
'test'
,
't'
)
->
extend
(
'PagerDefault'
);
$query
->
fields
(
't'
,
array
(
'age'
))
->
orderBy
(
'age'
)
->
limit
(
5
);
$outer_query
=
db_select
(
$query
);
$outer_query
->
addField
(
'subquery'
,
'age'
);
$ages
=
$outer_query
->
execute
()
->
fetchCol
();
$this
->
assertEqual
(
$ages
,
array
(
25
,
26
,
27
,
28
),
'Inner pager query returned the correct ages.'
);
}
/**
* Confirm that a paging query with a having expression returns valid results.
*
* This is a regression test for #467984.
*/
function
testHavingPagerQuery
()
{
$query
=
db_select
(
'test'
,
't'
)
->
extend
(
'PagerDefault'
);
$query
->
fields
(
't'
,
array
(
'age'
))
->
orderBy
(
'age'
)
->
having
(
'COUNT(age) > :count'
,
array
(
':count'
=>
1
))
->
limit
(
5
);
$ages
=
$query
->
execute
()
->
fetchCol
();
$this
->
assertEqual
(
$ages
,
array
(
25
),
' pager query with having expression returned the correct ages.'
);
}
}
...
...
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