When I attempt to add a datetime field to a node type I getting the following errors:

Notice: Undefined index: datetime:normal in DatabaseSchema_mysql->processField() (line 192 of /Library/WebServer/clients/reliefweb/includes/database/mysql/schema.inc).

There was a problem creating field asdf: SQLSTATE[42000]: Syntax error or access violation: 1064 You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'DEFAULT NULL, PRIMARY KEY (`etid`, `entity_id`, `deleted`, `delta`, `language`)' at line 9.

...and the field is not created. I'm running HEAD as of Sept. 27th with the patch from #918134

Comments

KarenS’s picture

jmiccolis’s picture

I read through that issue and I'm not really sure I understand how we're supposed to use an `_alter` to get this information through to the database as it writes the columns.

It looks like the type we use for a field is compared to a list of acceptable field types in `DatabaseSchema_mysql::getFieldTypeMap`and after that point, as the field module generates our schema we should use the schema_alter to swap that dummy value for something we know the current database will work with.

Is that right? Or am I missing something, because that is 1) far to messy and 2) puts date modules in a position of dictating what databases it support for a really common field type.

KarenS’s picture

Core used to provide a datatime type in schema.inc but it has been removed. I complained about that and was told that I should just do a schema_alter() in the Date module to add the type back in, which I have done. At some point I could create a datetime field in the Date module with that change, but it no longer works for some reason.

According to Damien Tournoud, the problem now is #927828: Some schema code incorrectly rely on the generic type instead of the engine-specific type and if that gets fixed my hook_schema_alter() will be sufficient again. That issue doesn't have a patch that passes tests, so I don't know if he's right that this will work again once core is patched.

KarenS’s picture

All of this would have been moot if they hadn't ripped datetime out of core.

KarenS’s picture

Priority: Normal » Critical
Status: Active » Postponed

Marking postponed and critical, meaning it's critical but won't get fixed until the core bug is fixed.

KarenS’s picture

Status: Postponed » Fixed

Just fixed in core. Yay!

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.