Skip to content

Commit 27255d0

Browse files
authored
Merge pull request #9 from TomHAnderson/hotfix/datetime-array
Convert strings to datetime when inside arrays
2 parents 683c751 + ea1c134 commit 27255d0

2 files changed

Lines changed: 14 additions & 2 deletions

File tree

src/Applicator.php

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -400,8 +400,10 @@ private function formatValue(string $value, string $fieldType, string $operator)
400400
case 'integer':
401401
return (int) $value;
402402

403-
case 'bigint':
404-
// bigint is handled as a string internally to PHP and cannot be typecast to an int
403+
case 'datetime':
404+
return new DateTime($value);
405+
406+
case 'bigint': // bigint is handled as a string internally to PHP
405407
default:
406408
return $value;
407409
}

test/ApplicatorTest.php

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -109,6 +109,16 @@ public function testBetween(): void
109109
$this->assertEquals(3, sizeof($queryBuilder->getQuery()->getResult()));
110110
}
111111

112+
public function testBetweenDates(): void
113+
{
114+
$filter = ['performanceDate|between' => '1995-02-21T00:00:00+00:00,1995-07-09T00:00:00+00:00'];
115+
116+
$applicator = (new Applicator($this->entityManager, Entity\Performance::class));
117+
$queryBuilder = $applicator($filter);
118+
119+
$this->assertEquals(2, sizeof($queryBuilder->getQuery()->getResult()));
120+
}
121+
112122
public function testLike(): void
113123
{
114124
$filter = ['name|like' => 'ish'];

0 commit comments

Comments
 (0)