Started seeing this error during a migration from Postgresql using a source migration.

SQLSTATE[22P02]: Invalid text representation: 7 ERROR:  invalid input syntax for integer: ""
LINE 4: WHERE  (map.sourceid1 = '') 
                                ^: SELECT map.destid1 AS destid1
FROM 
{migrate_map_files} map
WHERE  (map.sourceid1 = :db_condition_placeholder_0) ; Array
(
    [:db_condition_placeholder_0] => 
)
 in MigrateSQLMap->lookupDestinationID() (line 315 of /.../modules/contrib/migrate/plugins/sources/sqlmap.inc).
Drush command terminated abnormally due to an unrecoverable error. 

I traced it back to the $source_key structure looking like this:

  array(0 => NULL)

In mysql querying an int field with myfield = '' works fine, in postgres it throws an error, which in turn throws an exception.

The attached patch resolves the issue in my testing.

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

jhedstrom’s picture

Patch above apparently fatal errors in php 5.3, looking into that now.

jhedstrom’s picture

Status: Active » Needs work

Also, based on the logic immediately above where the patch was, this should have already been skipping these.

Gold’s picture

@jhedstrom, is this still an issue for you? I'm experiencing the same problem and have a similar environment. Will pick this up now too...

jhedstrom’s picture

@Gold I don't recall how we worked around this unfortunately.

Gold’s picture

Status: Needs work » Needs review
FileSize
603 bytes

Got it sorted. PHP5.3 doesn't like the output from array_unique() being passed straight into empty().

The following gets past that and allows the process to complete on a postgresql based site.

  • mikeryan committed 91db890 on 7.x-2.x
    Issue #2157933 by jhedstrom,Gold: Fix PostreSQL error with empty source...
mikeryan’s picture

Status: Needs review » Fixed

Committed, thanks!

mikeryan’s picture

Issue tags: +Migrate 2.6

Status: Fixed » Closed (fixed)

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