DateTime logged as 'null' in Doctrine query log
TheBabaYaga opened this issue · 9 comments
It seems that a DateTime in the query is logged as null. Is this expected behaviour?
Log:
WHERE t0.requested_date = ? AND ((t0.deleted_at IS NULL)) --> 'query params': [null]
I would expect something like:
WHERE t0.requested_date = ? AND ((t0.deleted_at IS NULL)) --> 'query params': [2016-07-24 07:55:56]
This is certainly strange. We transform variables into strings using Yaml::dump()
so the datetime should be dumped as expected.
Well I tried the following:
EasyLogFormatter:
dump($record);
$contextAsString = Yaml::dump($context, $this->getInlineLevel($record), $this->prefixLength);
die(dump($contextAsString));
Outcome:
array:7 [
"message" => "SELECT COUNT(a0_.id) AS sclr_0 FROM apps_absence a0_ WHERE (a0_.user_id = ? AND a0_.is_bookable = ? AND a0_.requested_date = ?) AND (a0_.deleted_at IS NULL)"
"context" => array:1 [
"query params" => array:3 [
0 => 2
1 => false
2 => DateTime {#1015
+"date": "2016-07-24 00:00:00"
+"timezone_type": 3
+"timezone": "UTC"
}
]
]
"level" => 100
"level_name" => "DEBUG"
"channel" => "doctrine"
"datetime" => DateTime {#1027
+"date": "2016-08-24 08:29:37"
+"timezone_type": 3
+"timezone": "UTC"
}
"extra" => []
]
"'query params': [2, false, null]\n"
I've just tested in a Symfony app and the DateTime object seems to be dumped as expected, including the timezone:
___ DOCTRINE ___________________________________________________________________________________
SELECT DISTINCT ... WHERE ... GROUP BY ... ASC LIMIT 10 OFFSET 0
--> 'query params': [true, 2016-08-26T07:19:45+02:00]
___ DOCTRINE ___________________________________________________________________________________
SELECT ... WHERE ... ORDER BY ... DESC
--> 'query params': [true, 2016-08-26T07:19:45+02:00, [40, 39, 38, 37, 36, 35, 34, 33, 32, 31]]
If you need any more information (php version, bundle version, etc...) to investigate this ticket please let me know.
Dunno if this is relevant, but the a0_.requested_date field is a DATE field, not a DATETIME field.
If it can further help you: it returns null in the yaml dump
Symfony\Component\Yaml\Inline
case is_object($value):
if ($objectSupport) {
return '!php/object:'.serialize($value);
}
if ($exceptionOnInvalidType) {
throw new DumpException('Object support when dumping a YAML file has been disabled.');
}
return 'null';
Is there an update about this issue?
@NoScopie it should be fixed by #6. Could you please test it? Thanks!
@javiereguiluz Jep this seems to fix it. Thanks!
___ DOCTRINE ___________________________________________________________________
SELECT COUNT(a0_.id) AS sclr_0 FROM apps_absence a0_ WHERE (a0_.user_id = ? AND a0_.requested_date
= ?) AND (a0_.deleted_at IS NULL)
--> 'query params': [4, '2017-06-03T00:00:00+00:00']