Skip to content

Commit 1eb42f8

Browse files
committed
Update whereDate
1 parent df61841 commit 1eb42f8

File tree

3 files changed

+10
-14
lines changed

3 files changed

+10
-14
lines changed

src/Query/Builder.php

Lines changed: 4 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1193,16 +1193,10 @@ protected function compileWhereDate(array $where): array
11931193
],
11941194
],
11951195
'ne' => [
1196-
'$or' => [
1197-
[
1198-
$where['column'] => [
1199-
'$lt' => $startOfDay,
1200-
],
1201-
],
1202-
[
1203-
$where['column'] => [
1204-
'$gt' => $endOfDay,
1205-
],
1196+
$where['column'] => [
1197+
'$not' => [
1198+
'$gte' => $startOfDay,
1199+
'$lte' => $endOfDay,
12061200
],
12071201
],
12081202
],

tests/Query/BuilderTest.php

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -663,9 +663,11 @@ function (Builder $builder) {
663663
];
664664

665665
yield 'where date !=' => [
666-
['find' => [['$or' => [
667-
['created_at' => ['$lt' => new UTCDateTime(new DateTimeImmutable('2018-09-30 00:00:00.000 +00:00'))]],
668-
['created_at' => ['$gt' => new UTCDateTime(new DateTimeImmutable('2018-09-30 23:59:59.999 +00:00'))]],
666+
['find' => [['created_at' => [
667+
'$not' => [
668+
'$gte' => new UTCDateTime(new DateTimeImmutable('2018-09-30 00:00:00.000 +00:00')),
669+
'$lte' => new UTCDateTime(new DateTimeImmutable('2018-09-30 23:59:59.999 +00:00')),
670+
],
669671
]], []]],
670672
fn (Builder $builder) => $builder->whereDate('created_at', '!=', '2018-09-30'),
671673
];

tests/QueryTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -220,7 +220,7 @@ public function testWhereDate(): void
220220
$this->assertCount(2, $birthdayCount);
221221

222222
$birthdayCount = Birthday::whereDate('birthday', '<>', '2021-05-11')->get();
223-
$this->assertCount(5, $birthdayCount);
223+
$this->assertCount(6, $birthdayCount);
224224
}
225225

226226
public function testWhereDay(): void

0 commit comments

Comments
 (0)