Closed felixgeyer closed 3 years ago
Hi everyone, after changing our timestamp format to Y-m-d\TH:i:s.u\Z we experienced issues with columns of type TIME: Invalid datetime format: 7 ERROR: invalid input syntax for type time: \"2021-10-27T08:00:00.000000Z\"
Y-m-d\TH:i:s.u\Z
TIME
Invalid datetime format: 7 ERROR: invalid input syntax for type time: \"2021-10-27T08:00:00.000000Z\"
This happens because there is no dedicated handling of TIME values. In 2.0.0-beta1 DATE values are already handled properly: https://github.com/propelorm/Propel2/commit/0018d43a4480fee50668ac902dae38149252ca24
DATE
I suggest to also add this for TIME values like this:
$script = ''; if ($column->getType() === PropelTypes::DATE) { $columnValueAccessor = $columnValueAccessor . ' ? ' . $columnValueAccessor . '->format("' . $this->getDateFormatter() . '") : null'; } elseif ($column->getType() === PropelTypes::TIME) { $columnValueAccessor = $columnValueAccessor . ' ? ' . $columnValueAccessor . '->format("' . $this->getTimeFormatter() . '") : null'; } elseif ($column->isTemporalType()) { $columnValueAccessor = $columnValueAccessor . ' ? ' . $columnValueAccessor . '->format("' . $this->getTimeStampFormatter() . '") : null'; } elseif ($column->isLobType()) { // we always need to make sure that the stream is rewound, otherwise nothing will // get written to database. $script .= " if (is_resource($columnValueAccessor)) { rewind($columnValueAccessor); }"; }
What do you think? If you agree, I can also make a PR for this change.
Go ahead and make a PR It will be easier to review and discuss it.
Sure :-) https://github.com/propelorm/Propel2/pull/1797
Hi everyone, after changing our timestamp format to
Y-m-d\TH:i:s.u\Z
we experienced issues with columns of typeTIME
:Invalid datetime format: 7 ERROR: invalid input syntax for type time: \"2021-10-27T08:00:00.000000Z\"
This happens because there is no dedicated handling of
TIME
values. In 2.0.0-beta1DATE
values are already handled properly: https://github.com/propelorm/Propel2/commit/0018d43a4480fee50668ac902dae38149252ca24I suggest to also add this for
TIME
values like this:What do you think? If you agree, I can also make a PR for this change.