Skip to content

Commit 1bebf0e

Browse files
committed
Fix for #259
1 parent e554921 commit 1bebf0e

File tree

2 files changed

+8
-3
lines changed

2 files changed

+8
-3
lines changed

api.php

+1-3
Original file line numberDiff line numberDiff line change
@@ -2036,9 +2036,7 @@ protected function listCommandInternal($parameters) {
20362036
$first_row = true;
20372037
foreach ($select[$table] as $field => $path) {
20382038
$values = $collect[$path[0]][$path[1]];
2039-
if ($values) {
2040-
$this->addFilter($filters,$table,'and',$field,'in',implode(',',$values));
2041-
}
2039+
$this->addFilter($filters,$table,'and',$field,'in',implode(',',$values));
20422040
if ($first_row) $first_row = false;
20432041
else echo ',';
20442042
echo '"'.$field.'":"'.implode('.',$path).'"';

tests/Tests.php

+7
Original file line numberDiff line numberDiff line change
@@ -653,4 +653,11 @@ public function testAddPostWithLeadingWhitespaceInJSON()
653653
$test->get('/posts/21');
654654
$test->expect('{"id":21,"user_id":1,"category_id":1,"content":"test whitespace"}');
655655
}
656+
657+
public function testListPostWithIncludeButNoRecords()
658+
{
659+
$test = new Api($this);
660+
$test->get('/posts?filter=id,eq,999&include=tags');
661+
$test->expect('{"posts":{"columns":["id","user_id","category_id","content"],"records":[]},"post_tags":{"relations":{"post_id":"posts.id"},"columns":["id","post_id","tag_id"],"records":[]},"tags":{"relations":{"id":"post_tags.tag_id"},"columns":["id","name"],"records":[]}}');
662+
}
656663
}

0 commit comments

Comments
 (0)