Attempting to migrate data from a table with CamelCase column names gave me errors like this…

Undefined property: stdClass::$CategoryID
File /var/www/d7/sites/all/modules/migrate/plugins/sources/sql.inc, line 336

The destination table was a node, and the nodes did get saved, but without titles (the only field I had mapped at the time).

Looking at line #336 I found that Migrate had converted the column names to lowercase, which is what appears to be causing the problem.

In the end I converted all column names to lowercase using this trick.

Comments

mikeryan’s picture

Status: Active » Closed (won't fix)

It's Drupal itself that lowercases field names on fetch. When defining your field mappings, use lowercase.

rt_davies’s picture

Status: Closed (won't fix) » Active

Am I missing something? The response is that this won't be fixed because Drupal doesn't support column names with upper case letters? But this is the migrate module--by definition it's dealing with *sources* of data that are not Drupal. It seems reasonable to expect that there will be data sources that have different naming conventions and should be supported.

moshe weitzman’s picture

We use Drupal core's database access layer. Consider opening an issue there to remove lowercasing.

Niklas Fiekas’s picture

If you have CategoryID just select that field. Then access it via categoryid - at least that worked for me. Even in the key schema. Since MySQL doesn't allow you to add CategoryID and categoryid to a table (afaik), this wasn't a problem.

mikeryan’s picture

Status: Active » Closed (won't fix)
Anonymous’s picture

I see why this can't be "fixed," and doesn't need to be, but I would suggest adding a big warning in the documentation that you must always lowercase the field names. Even though this is a core issue, Migrate may be the first time someone is working with this database layer. And this is the kind of error that doesn't throw an error, at least not in drush, so new users of Migrate can get lost trying to figure out what's wrong.

If there already is a warning, my bad for missing it. :)