Skip to content

Commit

Permalink
Fix #2244
Browse files Browse the repository at this point in the history
  • Loading branch information
dreamsxin committed Mar 29, 2014
1 parent 75276a4 commit dfcb39b
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 2 deletions.
2 changes: 1 addition & 1 deletion ext/mvc/model/manager.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
2 changes: 1 addition & 1 deletion ext/mvc/model/query/builder.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
13 changes: 13 additions & 0 deletions unit-tests/ModelsRelationsTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,7 @@ public function testModelsMysql()
$this->_executeTestsNormal($di);
$this->_executeTestsRenamed($di);
$this->_testIssue938($di);
$this->_testIssue2244($di);
}

public function testModelsPostgresql()
Expand Down Expand Up @@ -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);
}
}

0 comments on commit dfcb39b

Please sign in to comment.