mirror of
https://github.com/phpbb/phpbb.git
synced 2025-04-21 00:02:18 +02:00
Merge remote-tracking branch 'github-nickvergessen/ticket/10296' into develop-olympus
* github-nickvergessen/ticket/10296: [ticket/10296] Fix CROSS JOIN with INNER JOIN on MSSQL, Postgres and Oracle [ticket/10296] Add unit test for CROSS JOIN with INNER JOIN
This commit is contained in:
commit
cfaf0e1e96
@ -609,7 +609,7 @@ class dbal
|
||||
}
|
||||
}
|
||||
|
||||
$sql .= $this->_sql_custom_build('FROM', implode(', ', $table_array));
|
||||
$sql .= $this->_sql_custom_build('FROM', implode(' CROSS JOIN ', $table_array));
|
||||
|
||||
if (!empty($array['LEFT_JOIN']))
|
||||
{
|
||||
|
55
tests/dbal/cross_join_test.php
Normal file
55
tests/dbal/cross_join_test.php
Normal file
@ -0,0 +1,55 @@
|
||||
<?php
|
||||
/**
|
||||
*
|
||||
* @package testing
|
||||
* @copyright (c) 2011 phpBB Group
|
||||
* @license http://opensource.org/licenses/gpl-license.php GNU Public License
|
||||
*
|
||||
*/
|
||||
|
||||
require_once dirname(__FILE__) . '/../../phpBB/includes/functions.php';
|
||||
require_once dirname(__FILE__) . '/../../phpBB/includes/utf/utf_tools.php';
|
||||
|
||||
class phpbb_dbal_cross_join_test extends phpbb_database_test_case
|
||||
{
|
||||
public function getDataSet()
|
||||
{
|
||||
return $this->createXMLDataSet(dirname(__FILE__).'/fixtures/massmail_crossjoin.xml');
|
||||
}
|
||||
|
||||
public function test_cross_join()
|
||||
{
|
||||
$db = $this->new_dbal();
|
||||
|
||||
// http://tracker.phpbb.com/browse/PHPBB3-10296
|
||||
// Test CROSS JOIN with INNER JOIN
|
||||
// Failed on Postgres, MSSQL and Oracle
|
||||
$db->sql_return_on_error(true);
|
||||
|
||||
$sql_ary = array(
|
||||
'SELECT' => 'u.username',
|
||||
'FROM' => array(
|
||||
'phpbb_users' => 'u',
|
||||
'phpbb_user_group' => 'ug',
|
||||
),
|
||||
'LEFT_JOIN' => array(
|
||||
array(
|
||||
'FROM' => array(
|
||||
'phpbb_banlist' => 'b',
|
||||
),
|
||||
'ON' => 'u.user_id = b.ban_userid',
|
||||
),
|
||||
),
|
||||
'WHERE' => 'ug.group_id = 1
|
||||
AND u.user_id = ug.user_id
|
||||
AND b.ban_id IS NULL',
|
||||
'ORDER_BY' => 'u.username',
|
||||
);
|
||||
$sql = $db->sql_build_query('SELECT', $sql_ary);
|
||||
$result = $db->sql_query($sql);
|
||||
|
||||
$db->sql_return_on_error(false);
|
||||
|
||||
$this->assertEquals(array(array('username' => 'mass email')), $db->sql_fetchrowset($result));
|
||||
}
|
||||
}
|
43
tests/dbal/fixtures/massmail_crossjoin.xml
Normal file
43
tests/dbal/fixtures/massmail_crossjoin.xml
Normal file
@ -0,0 +1,43 @@
|
||||
<?xml version="1.0" encoding="UTF-8" ?>
|
||||
<dataset>
|
||||
<table name="phpbb_banlist">
|
||||
<column>ban_id</column>
|
||||
<column>ban_userid</column>
|
||||
<row>
|
||||
<value>1</value>
|
||||
<value>2</value>
|
||||
</row>
|
||||
</table>
|
||||
<table name="phpbb_users">
|
||||
<column>user_id</column>
|
||||
<column>username</column>
|
||||
<column>username_clean</column>
|
||||
<row>
|
||||
<value>1</value>
|
||||
<value>mass email</value>
|
||||
<value>mass email</value>
|
||||
</row>
|
||||
<row>
|
||||
<value>2</value>
|
||||
<value>banned</value>
|
||||
<value>banned</value>
|
||||
</row>
|
||||
<row>
|
||||
<value>3</value>
|
||||
<value>not in group</value>
|
||||
<value>not in group</value>
|
||||
</row>
|
||||
</table>
|
||||
<table name="phpbb_user_group">
|
||||
<column>user_id</column>
|
||||
<column>group_id</column>
|
||||
<row>
|
||||
<value>1</value>
|
||||
<value>1</value>
|
||||
</row>
|
||||
<row>
|
||||
<value>2</value>
|
||||
<value>1</value>
|
||||
</row>
|
||||
</table>
|
||||
</dataset>
|
Loading…
x
Reference in New Issue
Block a user