Skip to content

Commit 94f86d0

Browse files
committed
fix: preserve datetime instants in visibility query bindings
1 parent 59e2ce1 commit 94f86d0

2 files changed

Lines changed: 5 additions & 4 deletions

File tree

‎app/Support/WorkflowVisibilityQuery.php‎

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
use Illuminate\Database\Eloquent\Builder;
77
use Illuminate\Support\Carbon;
88
use Illuminate\Validation\ValidationException;
9+
use Workflow\V2\Support\UtcScheduleTimestamp;
910

1011
class WorkflowVisibilityQuery
1112
{
@@ -744,15 +745,15 @@ private function coerceBool(mixed $literal, string $field): bool
744745
throw $this->invalidValue($field, 'a boolean literal');
745746
}
746747

747-
private function coerceDatetime(mixed $literal, string $field): Carbon
748+
private function coerceDatetime(mixed $literal, string $field): string
748749
{
749750
if ($literal instanceof \DateTimeInterface) {
750-
return Carbon::instance($literal);
751+
return UtcScheduleTimestamp::databaseValue($literal);
751752
}
752753

753754
if (is_string($literal) || is_int($literal) || is_float($literal)) {
754755
try {
755-
return Carbon::parse($literal);
756+
return UtcScheduleTimestamp::databaseValue(Carbon::parse($literal));
756757
} catch (\Throwable) {
757758
throw $this->invalidValue($field, 'a datetime literal');
758759
}

‎tests/Feature/WorkflowSearchAttributeVisibilityQueryTest.php‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -234,7 +234,7 @@ public function test_datetime_visibility_preserves_offset_instants_and_microseco
234234
$this->assertSame(['wf-date-match'], $this->workflowIdsForQuery('occurred_at = "'.$literal.'"'));
235235
$this->assertSame(['wf-date-neighbor'], $this->workflowIdsForQuery('occurred_at != "'.$literal.'"'));
236236
$this->assertSame(['wf-date-match'], $this->workflowIdsForQuery('occurred_at IN ("'.$literal.'")'));
237-
$this->assertSame(['wf-date-neighbor'], $this->workflowIdsForQuery('occurred_at NOT IN ("'.$literal.'")'));
237+
$this->assertSame(['wf-date-neighbor'], $this->workflowIdsForQuery('NOT occurred_at IN ("'.$literal.'")'));
238238
$this->assertSame(['wf-date-match'], $this->workflowIdsForQuery(
239239
'occurred_at >= "'.$literal.'" AND occurred_at < "2026-10-08T10:34:56.123457Z"',
240240
));

0 commit comments

Comments
 (0)