Skip to content

Commit

Permalink
Orm fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
AntonOkulov committed Nov 17, 2019
1 parent f19c3eb commit 0119327
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 1 deletion.
3 changes: 3 additions & 0 deletions src/Phact/Orm/LookupManager.php
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,9 @@ public function processContains($query, $column, $value, $operator)
*/
public function processIn($query, $column, $value, $operator)
{
if (empty($value)) {
return QueryLayer::buildWhere(1, '=', 0, $operator);
}
return QueryLayer::buildWhere($column, 'IN', $value, $operator);
}

Expand Down
2 changes: 1 addition & 1 deletion src/Phact/Orm/Model.php
Original file line number Diff line number Diff line change
Expand Up @@ -496,7 +496,7 @@ protected function _provideEvent($eventName)
$this->{$metaEvent}();
if ($event) {
$event->trigger(self::class . '::' . $metaEvent, [], $this);
$event->trigger('model.' . $eventName, [], $this);
$event->trigger('model.' . $metaEvent, [], $this);
}
}
}
Expand Down
2 changes: 2 additions & 0 deletions tests/Cases/Orm/Abs/AbstractQuerySetTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -549,6 +549,8 @@ public function testWithAll()
$this->assertCount(1, $books);
$this->assertInstanceOf(Book::class, $books[0]);
$this->assertEquals('Second book', $books[0]->name);

$this->assertEquals([], Author::objects()->filter(['id' => 100])->with(['books'])->all());
}

public function testWithValues()
Expand Down

0 comments on commit 0119327

Please sign in to comment.