tbaddade / redaxo_url

REDAXO 5 AddOn zur URL-Generierung für eigene AddOns (ehemals Url Control, ehemals Frau Schultze)
MIT License
46 stars 22 forks source link

ERROR 1525 (HY000): Incorrect DATETIME value #285

Closed tbaddade closed 1 month ago

tbaddade commented 10 months ago

Sobald ein Date Feld für die Url verwendet wird, darf nicht auf != '' an dieser Stelle geprüft werden

https://support.oracle.com/knowledge/Oracle%20Database%20Products/2725151_1.html

The server requires that month and day values be valid, and not merely in the range 1 to 12 and 1 to 31, respectively. With strict mode disabled, invalid dates such as '2004-04-31' are converted to '0000-00-00' and a warning is generated. With strict mode enabled, invalid dates generate an error. To permit such dates, enable ALLOW_INVALID_DATES. (https://dev.mysql.com/doc/refman/8.0/en/datetime.html)

alxndr-w commented 7 months ago

Das kann ich bestätigen. Es wird ein SQL-Befehl wie dieser generiert:

SELECT `data`.`id` AS `id`, `data`.`id` AS `data_id`, `data`.`c_teaser` AS `data_seo_description`, 
`data`.`c_image` AS `data_seo_image`, `data`.`c_name` AS `data_seo_title`, `data`.`name_short` AS `data_segment_part_1`, 
`data`.`startDate` AS `data_segment_part_2`, `data`.`startTime` AS `data_segment_part_3` FROM `rex_msg_event_url` AS `data` 
WHERE ((data.name_short != "" AND `data`.`name_short` IS NOT NULL OR data.startDate != "" AND `data`.`startDate` IS NOT NULL 
OR data.startTime != "" AND `data`.`startTime` IS NOT NULL)) AND (data.c_status > '0') ORDER BY `data_id` ASC

Und dieser führt zu Fehler in der SQL-Abfrage (1525): Incorrect DATE value: ''

alxndr-w commented 7 months ago

Ergänzend dadurch noch: Eine alternative wäre, den Wert als char zu casten: https://dev.mysql.com/doc/refman/8.0/en/cast-functions.html

Das habe ich eben (bereits an der VIEW, die als Profil herangezogen wird) ausprobiert und führt dann logischerweise nicht mehr zu dem Fehler.

isospin commented 4 months ago

https://github.com/tbaddade/redaxo_url/pull/295

tbaddade commented 1 month ago

Fixed #295