From dfcb39b94316495f77d2fa9b6f685e3273e3d849 Mon Sep 17 00:00:00 2001 From: dreamsxin Date: Sat, 29 Mar 2014 16:54:51 +0800 Subject: [PATCH] Fix #2244 --- ext/mvc/model/manager.c | 2 +- ext/mvc/model/query/builder.c | 2 +- unit-tests/ModelsRelationsTest.php | 13 +++++++++++++ 3 files changed, 15 insertions(+), 2 deletions(-) diff --git a/ext/mvc/model/manager.c b/ext/mvc/model/manager.c index c6138794d63..5561626889a 100644 --- a/ext/mvc/model/manager.c +++ b/ext/mvc/model/manager.c @@ -2270,7 +2270,7 @@ PHP_METHOD(Phalcon_Mvc_Model_Manager, getRelationRecords){ RETURN_MM(); } - if (Z_TYPE_P(pre_conditions) != IS_NULL) { + if (PHALCON_IS_NOT_EMPTY(pre_conditions)) { PHALCON_INIT_NVAR(conditions); array_init_size(conditions, 1); phalcon_array_append(&conditions, pre_conditions, PH_SEPARATE); diff --git a/ext/mvc/model/query/builder.c b/ext/mvc/model/query/builder.c index 1c0fcacfa10..0e39791d70d 100644 --- a/ext/mvc/model/query/builder.c +++ b/ext/mvc/model/query/builder.c @@ -1777,7 +1777,7 @@ PHP_METHOD(Phalcon_Mvc_Model_Query_Builder, getPhql){ */ PHALCON_OBS_VAR(order); phalcon_read_property_this(&order, this_ptr, SL("_order"), PH_NOISY TSRMLS_CC); - if (Z_TYPE_P(order) != IS_NULL) { + if (PHALCON_IS_NOT_EMPTY(order)) { if (Z_TYPE_P(order) == IS_ARRAY) { PHALCON_INIT_VAR(order_items); diff --git a/unit-tests/ModelsRelationsTest.php b/unit-tests/ModelsRelationsTest.php index 964e032bc03..71084146fc0 100644 --- a/unit-tests/ModelsRelationsTest.php +++ b/unit-tests/ModelsRelationsTest.php @@ -75,6 +75,7 @@ public function testModelsMysql() $this->_executeTestsNormal($di); $this->_executeTestsRenamed($di); $this->_testIssue938($di); + $this->_testIssue2244($di); } public function testModelsPostgresql() @@ -367,4 +368,16 @@ protected function _testIssue938($di) $this->assertEquals($rp[$i]->robots_id, $robot->id); } } + + protected function _testIssue2244($di) + { + $options = array('order' => '', 'conditions' => ''); + + $robot = RelationsRobots::findFirst(); + $this->assertNotEquals($robot, false); + + $robotsParts = $robot->getRelationsRobotsParts($options); + $this->assertEquals(get_class($robotsParts), 'Phalcon\Mvc\Model\Resultset\Simple'); + $this->assertEquals(count($robotsParts), 3); + } }