Skip to content

Commit

Permalink
Handle date and time based where clauses
Browse files Browse the repository at this point in the history
  • Loading branch information
harrygulliford committed Oct 16, 2024
1 parent d32fb50 commit e95a50f
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions src/Query/Grammars/FirebirdGrammar.php
Original file line number Diff line number Diff line change
Expand Up @@ -166,9 +166,13 @@ protected function wrapUnion($sql)
*/
protected function dateBasedWhere($type, Builder $query, $where)
{
$value = $this->parameter($where['value']);
$condition = ($type === 'date' || $type === 'time')
? 'cast('.$this->wrap($where['column']).' as '.$type.') '
: 'extract('.$type.' from '.$this->wrap($where['column']).') ';

return 'EXTRACT('.$type.' FROM '.$this->wrap($where['column']).') '.$where['operator'].' '.$value;
$condition .= $where['operator'].' '.$this->parameter($where['value']);

return $condition;
}

/**
Expand Down

0 comments on commit e95a50f

Please sign in to comment.