The change date format tool is broken, and it breaks the existing stored information.

When changing the date field to date ISO format it converts the field to:
sql_format('Y-m-d/TH:i:s', $db_field)
The problem is that it leaves an extra / in the date field than breaks any future date field function over this field.

When changing from date or datetime to datestamp (unixtime) it always returns 0.
The function sql_format($format, $field) (date_api_sql.inc) in
$date_handler->sql_format('U', $db_field) . ' AS ' . $info['column']; (date_tools_change_type.inc)
returns "DATE_FORMAT($field, '$format')"; so DATE_FORMAT($field, 'U');
That doesn't exist:
http://dev.mysql.com/doc/refman/5.0/es/date-and-time-functions.html
http://dev.mysql.com/doc/refman/5.1/en/date-and-time-functions.html#func...

This created the problem reported in other issue about breaking the views functionality and not showing date fields anymore (at least in my case) and probably some other ones.

The problem is that once the date field was converted to this wrong format, trying to revert it to another format breaks everything badly losing the original date values (thank you backups!!)

This patch:
- It use the defined format in: define('DATE_FORMAT_ISO', "Y-m-d\TH:i:s"); and change the SQL function in the date_tools_change_type_form_submit() function.
- it adds a new transformation in date_api_sql.inc sql_format () function (it could be hardcoded in the date_tools_change_type_form_submit() functions as well), but I don't know the corresponding postgres
equivalence.

This is just the patch for using the right format but there should be an update function to fix existing broken fields or recommend people to restore a backup.
The question is that probably this unfinished feature shouldn't be in an stable release and it should live only in a devel release for testing and debugging.

CommentFileSizeAuthor
date_change_type_tools.patch1.72 KBjcmarco
Support from Acquia helps fund testing for Drupal Acquia logo

Comments

DamienMcKenna’s picture

Status: Needs review » Closed (won't fix)

Unfortunately the D6 version of this module is no longer supported, but we appreciate the time you put into this. If this problem is relevant for D7 too, please reopen the issue. Thanks.