You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The thing is, that it's really nice, that database layout returns the \DateInterval object (instead of \DateTime object) on select from time column, but in that case I'll expect, that database layout will also be able to work with \DateInterval object on insert/update or everywhere else, e.g.:
// Database layout can't process object \DateInterval so it tries to convert it into string// An Exception in throw due to \DateInterval doesn't have implemented __toString method$database->table("scheduler")->insert(array(..., "interval" => new \DateInterval("PT1H"), ...));
Or another example:
$activeRow = $database->table("scheduler")->where("id", 5)->fetch();
$interval = clone $activeRow->interval;
$interval->h++;
$activeRow->update(array("interval" => $interval)); // Same problem as above
There are two ways how to deal with this problem:
Extend ISupplementalDriver interface by method formatInterval & fix method formatValue in class SqlPreprocessor to use it if value is instance of \DateInterval
Create \Nette\Utils\DateInterval class (like \Nette\Utils\DateTime) which will extend class \DateInterval by function __toString & fix method normalizeRow in class ResultSet to use this new object instead of php \DateInterval
I prefer the first option, but it's up to you guys :)
If you don't have anything against this, I'd like to resolve this issue & create pull request. (Because this term at school I have a subject called Open-Source Programming in which I have to join some running open source project & resolve some issues.) :D
Thanks for your attention,
and I'll look forward to your reply.
The text was updated successfully, but these errors were encountered:
mdjimy
changed the title
Problem with DateInterval on insert/update
Problem with \DateInterval object on insert/update
Mar 12, 2015
Hi,
I'm reacting on BC break in the issue nette/nette#1213.
The thing is, that it's really nice, that database layout returns the \DateInterval object (instead of \DateTime object) on select from time column, but in that case I'll expect, that database layout will also be able to work with \DateInterval object on insert/update or everywhere else, e.g.:
Or another example:
There are two ways how to deal with this problem:
I prefer the first option, but it's up to you guys :)
If you don't have anything against this, I'd like to resolve this issue & create pull request. (Because this term at school I have a subject called Open-Source Programming in which I have to join some running open source project & resolve some issues.) :D
Thanks for your attention,
and I'll look forward to your reply.
The text was updated successfully, but these errors were encountered: