Skip to content

Commit

Permalink
[4.x] Fix single digit month not working on whereMonth (#8697)
Browse files Browse the repository at this point in the history
  • Loading branch information
arifhp86 authored Sep 19, 2023
1 parent 438ad5a commit 8433adb
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/Stache/Query/Builder.php
Original file line number Diff line number Diff line change
Expand Up @@ -190,7 +190,7 @@ protected function filterWhereMonth($values, $where)
return false;
}

return $this->{$method}($value->format('m'), $where['value']);
return $this->{$method}($value->format('m'), sprintf('%02d', $where['value']));
});
}

Expand Down
5 changes: 5 additions & 0 deletions tests/Data/Entries/EntryQueryBuilderTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,11 @@ public function entries_are_found_using_where_month()
$this->assertCount(3, $entries);
$this->assertEquals(['Post 1', 'Post 2', 'Post 3'], $entries->map->title->all());

$entries = Entry::query()->whereMonth('test_date', 9)->get();

$this->assertCount(1, $entries);
$this->assertEquals(['Post 4'], $entries->map->title->all());

$entries = Entry::query()->whereMonth('test_date', '<', 11)->get();

$this->assertCount(1, $entries);
Expand Down

0 comments on commit 8433adb

Please sign in to comment.