This is related to this issue: http://drupal.org/node/1631014#comment-form
Probably should be fixed or better explained in Feeds Sql documentation …

Comments

rmathew’s picture

Title: Fields names in source tables should be lowercase, otherwise Feeds Sql will output any result » Field names must be lowercase. No result is output for fields with names containing uppercase characters

It's the field names in the SQL query that matter - if you have any uppercase character in the field name then no result will be returned for that field.

Fortunately there is a workaround, at least with mysql - simply use lowercase in the SQL query under /import/[importername]. For example, if you have:

+---------+
| Field   |
+---------+
| ID      |
| Name    |
+---------+

Fails : select * from tblname
Fails : select ID, Name from tblname

Works : select id, name from tblname

mortona2k’s picture

Yup, I'm seeing the same.

adanbouzoua’s picture

Priority: Normal » Critical

I'm getting the same error trying to import from MS SQL 2008 .
I spent days identifying the error because setting ID (uppercase) as "Unique Target" failed.

But work when field name are in lower case

stevenx’s picture

I looked trough the Feeds SQL module but could not find where it crashes.
I confirm the error as mentioned in #1

Might be in the Feeds module itself somewhere?

Outdoor Ed’s picture

This is especially confusing since in the SQL Query Parser if you enter Uppercase or Mixed Case the query runs and shows you the sample records to be imported. Then when you actually run the importer nothing comes across (at least from SQL Server). There should be specific documentation talking about this.

jrandell’s picture

OMFG!!!
three days on this, and all it took was lowercase!

Dear Mr. Maintainer,
While I am a bit irritated, your horse is still a lovely gift. Even if it took a great deal of effort to fix the mouth, I am grateful to you!

mpotter’s picture

Issue summary: View changes

This also caused a problem for me. Could not figure out why I was getting "Term name missing" when trying to import taxonomy terms. The column was uppercase and using the comment from #1 fixed it.

Johann Wagner’s picture

I think this special case must be made public.

I think of a warning message on this project page or on the pre-fetcher page.

On this pre-fetch results page, uppercase columns are still shown and results are correct.

Thank you.

nattyweb’s picture

Oh for goodness' sake. I have spent HOURS over many days on trying to debug my import and all that was at fault was the case of the fields in my import table.
Thanks to all for documenting this 'feature', especially to those posting recently so I knew this was still a current issue.

LGLC’s picture

Status: Active » Needs review
StatusFileSize
new990 bytes

This can be extremely frustrating, especially as there are no error messages to indicate anything is going wrong. I've written a patch to force the Fetcher to convert any query to lowercase, as suggested in [#1631014]. You may need to clear your cache after applying the patch.

The other option would be to stop the Parser converting the elements to lowercase (i.e. deleting the getSourceElement() override from FeedsSQLParser.inc), but I wasn't sure if that would have any other unintended consequences, so this seemed the safest way to go.

LGLC’s picture

StatusFileSize
new1.21 KB

Whoops, forgot to use the new FeedsSQLFetcherResult. New patch attached.

eabquina’s picture

This solved my issue. It was just that all along!

Raher’s picture

I lost hours on this problem! Thank you

alibama’s picture

fixed my import... RTBC?

kekkis’s picture

StatusFileSize
new751 bytes

It doesn't fix for example feeds_tamper's 'Blank source' case.

I suggest we still explore removing the override of FeedsParser::getSourceElement as per [#1631014]. What is the harm this may cause? Or better, why was the override added in the first place? Anyway, attaching the patch for others to test.

darren oh’s picture

Status: Needs review » Reviewed & tested by the community

Removing the override works. The override was copied from the FeedsCSVParser class. It is causing problems because the FeedsSQLParser class is not an instance of FeedsCSVParser. There is no harm in removing it.

fool2’s picture

Can someone please please please commit this? It is insane how many hours this is wasting still and it was solved months ago!

I am going to describe the problem I was having here, in hopes that someone will find this patch when googling-- my node import using feeds_sql was succeeding but I was losing some fields--I was getting blank fields from the import even though they showed fine in feeds_import_preview! I stumbled on this issue before noticing that it was only the fields that had column names with capital letters in them.

Patch applies wonderfully, and this module is awesome otherwise.

fool2’s picture

I have been thinking about this more, and I am thinking that maybe we should use PDO::CASE_LOWER to solve this instead.

http://php.net/manual/en/pdo.setattribute.php

This will force all columns coming out of this to be lowercase. It shouldn't affect any other database connections-- if it does we need to make sure not to leave the attribute set after the process has completed. I am noticing some other modules (feeds_profile2) having problems with case as well, probably due to the output of this module, so this patch isn't a full solution because of how other modules might be treating the data.

anybody’s picture

I can confirm this issue still exists and the patch solves it. Could you create a new release containing this fix?