Skip to content

Commit

Permalink
Update Postgres Datediff
Browse files Browse the repository at this point in the history
There was a problem when using:
$query -> func() -> dateDiff( [ 'COALESCE(Articles.modified, Articles.created)' => 'literal', date( "Y-m-d H:i:s" ) ] )
  • Loading branch information
Ladislav Gallay committed Oct 20, 2014
1 parent f9aaec9 commit 3515b41
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions src/Database/Dialect/PostgresDialectTrait.php
Expand Up @@ -101,10 +101,15 @@ protected function _transformFunctionExpression(FunctionExpression $expression)
break;
case 'DATEDIFF':
$expression
->name('')
->name('ABS')
->type('-')
->iterateParts(function ($p) {
return new FunctionExpression('DATE', [$p['value']], [$p['type']]);
if( is_string($p) )
$p = [ 'value' => [$p => 'literal'], 'type' => null ];
else
$p['value'] = [$p['value']];

return new FunctionExpression('DATE', $p['value'], [$p['type']]);
});
break;
case 'CURRENT_DATE':
Expand Down

0 comments on commit 3515b41

Please sign in to comment.