I have tested Migrate with custom datas, using PostgreSQL.

I encouter this error :

Migration failed with source plugin exception: SQLSTATE[42703]: Undefined column: 7 ERREUR:  la colonne d.id n'existe pas                               [error]
LINE 4: ...UTER JOIN client.public.migrate_map_directory map ON d.ID = map...
                                                             ^: SELECT d."ID" AS "ID", d."Email" AS "Email", d."Lastname" AS "Lastname", d."Firstname" AS "Firstname",
map.sourceid1 AS migrate_map_sourceid1, map.source_row_status AS migrate_map_source_row_status
FROM 
{v2_directory} d
LEFT OUTER JOIN client.public.migrate_map_directory map ON d.ID = map.sourceid1
WHERE ( (map.sourceid1 IS NULL ) OR (map.source_row_status = :db_condition_placeholder_0) ); Array
(
    [:db_condition_placeholder_0] => 1
)

I've tested this SQL query in PG, the error is the same.

I've managed to fix the query using quotes (on the "ON" statement), as following :

SELECT d."ID" AS "ID", d."Email" AS "Email", d."Lastname" AS "Lastname", d."Firstname" AS "Firstname",
map.sourceid1 AS migrate_map_sourceid1, map.source_row_status AS migrate_map_source_row_status
FROM 
v2_directory d
LEFT OUTER JOIN client.public.migrate_map_directory map ON d."ID" = map.sourceid1
WHERE ( (map.sourceid1 IS NULL ) OR (map.source_row_status = 1) );
Support from Acquia helps fund testing for Drupal Acquia logo

Comments

Haza created an issue. See original summary.

Haza’s picture

Status: Active » Needs review
FileSize
773 bytes

Here is a minor patch that always add quotes around the join.

Haza’s picture

Issue summary: View changes
Haza’s picture

Issue summary: View changes
Haza’s picture

Oops, just removed the silly string concatenation.

The last submitted patch, 2: migrate_fails_to_build-2552547-2.patch, failed testing.

Status: Needs review » Needs work

The last submitted patch, 5: migrate_fails_to_build-2552547-5.patch, failed testing.

Status: Needs work » Needs review
bzrudi71’s picture

Priority: Normal » Major
Issue tags: +PostgreSQL

Thanks @Haza! Adding tags and starting PG bot test run.

bzrudi71’s picture

Status: Needs review » Needs work
Issue tags: +Needs reroll
Nikolay Shapovalov’s picture

Status: Needs work » Needs review
Issue tags: -Needs reroll
FileSize
752 bytes

Rerolled

bzrudi71’s picture

Status: Needs review » Needs work

Thanks! Can we please make use of Database::escapeField() function instead of simple quoting? It will handle all the required quoting and some other magic for us :-) Please see Connection.php for details...

Haza’s picture

New patch that uses the Database::escapeField() function.

bzrudi71’s picture

catch’s picture

Issue tags: +Migrate critical
phenaproxima’s picture

Status: Needs review » Reviewed & tested by the community

Nice and easy; escaping the field name seems like a great idea in all cases, not just for Postgres support. RTBC!

webchick’s picture

Status: Reviewed & tested by the community » Fixed

Committed and pushed to 8.0.x. Thanks!

  • webchick committed c0f0df5 on 8.0.x
    Issue #2552547 by Haza, zniki.ru, bzrudi71: Migrate fails to build the...

Status: Fixed » Closed (fixed)

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