Skip to content
This repository was archived by the owner on Oct 2, 2019. It is now read-only.

Commit c630cda

Browse files
committed
add unittest for nested functions in columns in Zend_Db_Select
1 parent fe0e60a commit c630cda

File tree

1 file changed

+20
-0
lines changed

1 file changed

+20
-0
lines changed

tests/Zend/Db/Select/StaticTest.php

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -854,6 +854,26 @@ public function testSqlInjectionInColumn()
854854
$this->assertEquals('SELECT "p"."MD5(1); drop table products; -- )" FROM "products" AS "p"', $select->assemble());
855855
}
856856

857+
public function testIfInColumn()
858+
{
859+
$select = $this->_db->select();
860+
$select->from('table1', '*');
861+
$select->join(array('table2'),
862+
'table1.id = table2.id',
863+
array('bar' => 'IF(table2.id IS NOT NULL, 1, 0)'));
864+
$this->assertEquals("SELECT \"table1\".*, IF(table2.id IS NOT NULL, 1, 0) AS \"bar\" FROM \"table1\"\n INNER JOIN \"table2\" ON table1.id = table2.id", $select->assemble());
865+
}
866+
867+
public function testNestedIfInColumn()
868+
{
869+
$select = $this->_db->select();
870+
$select->from('table1', '*');
871+
$select->join(array('table2'),
872+
'table1.id = table2.id',
873+
array('bar' => 'IF(table2.id IS NOT NULL, IF(table2.id2 IS NOT NULL, 1, 2), 0)'));
874+
$this->assertEquals("SELECT \"table1\".*, IF(table2.id IS NOT NULL, IF(table2.id2 IS NOT NULL, 1, 2), 0) AS \"bar\" FROM \"table1\"\n INNER JOIN \"table2\" ON table1.id = table2.id", $select->assemble());
875+
}
876+
857877
/**
858878
* @group ZF-378
859879
*/

0 commit comments

Comments
 (0)