|
|
@@ -141,4 +141,61 @@ class Zend_Db_Table_Select_Pdo_PgsqlTest extends Zend_Db_Table_Select_TestCommon
|
|
|
$select->from(array('p' => 'products'))->order('name;select;MD5(1)');
|
|
|
$this->assertEquals('SELECT "p".* FROM "products" AS "p" ORDER BY "name;select;MD5(1)" ASC', $select->assemble());
|
|
|
}
|
|
|
+
|
|
|
+ /**
|
|
|
+ * @group ZF-378
|
|
|
+ */
|
|
|
+ public function testOrderOfSingleFieldWithDirection()
|
|
|
+ {
|
|
|
+ $select = $this->_db->select();
|
|
|
+ $select->from(array ('p' => 'product'))
|
|
|
+ ->order('productId DESC');
|
|
|
+
|
|
|
+ $expected = 'SELECT "p".* FROM "product" AS "p" ORDER BY "productId" DESC';
|
|
|
+ $this->assertEquals($expected, $select->assemble(),
|
|
|
+ 'Order direction of field failed');
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * @group ZF-378
|
|
|
+ */
|
|
|
+ public function testOrderOfMultiFieldWithDirection()
|
|
|
+ {
|
|
|
+ $select = $this->_db->select();
|
|
|
+ $select->from(array ('p' => 'product'))
|
|
|
+ ->order(array ('productId DESC', 'userId ASC'));
|
|
|
+
|
|
|
+ $expected = 'SELECT "p".* FROM "product" AS "p" ORDER BY "productId" DESC, "userId" ASC';
|
|
|
+ $this->assertEquals($expected, $select->assemble(),
|
|
|
+ 'Order direction of field failed');
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * @group ZF-378
|
|
|
+ */
|
|
|
+ public function testOrderOfMultiFieldButOnlyOneWithDirection()
|
|
|
+ {
|
|
|
+ $select = $this->_db->select();
|
|
|
+ $select->from(array ('p' => 'product'))
|
|
|
+ ->order(array ('productId', 'userId DESC'));
|
|
|
+
|
|
|
+ $expected = 'SELECT "p".* FROM "product" AS "p" ORDER BY "productId" ASC, "userId" DESC';
|
|
|
+ $this->assertEquals($expected, $select->assemble(),
|
|
|
+ 'Order direction of field failed');
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * @group ZF-378
|
|
|
+ * @group ZF-381
|
|
|
+ */
|
|
|
+ public function testOrderOfConditionalFieldWithDirection($adapter)
|
|
|
+ {
|
|
|
+ $select = $this->_db->select();
|
|
|
+ $select->from(array ('p' => 'product'))
|
|
|
+ ->order('IF("productId" > 5,1,0) ASC');
|
|
|
+
|
|
|
+ $expected = 'SELECT "p".* FROM "product" AS "p" ORDER BY IF("productId" > 5,1,0) ASC';
|
|
|
+ $this->assertEquals($expected, $select->assemble(),
|
|
|
+ 'Order direction of field failed');
|
|
|
+ }
|
|
|
}
|