From 29d27ec2ef157c71d27f8b3eef5b0136a3995b58 Mon Sep 17 00:00:00 2001 From: Gerhard Schlager Date: Wed, 30 Sep 2015 16:38:06 +0200 Subject: [PATCH] FIX: Prevent cast error when import_id contains strings and numbers Some importers insert numbers and strings as import_id into the same custom_fields table. This change prevents cast errors during imports. --- script/import_scripts/base.rb | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/script/import_scripts/base.rb b/script/import_scripts/base.rb index 57bbc24e9d9..dda270aacee 100644 --- a/script/import_scripts/base.rb +++ b/script/import_scripts/base.rb @@ -198,12 +198,7 @@ class ImportScripts::Base return false if import_ids.empty? existing = "#{type.to_s.classify}CustomField".constantize.where(name: 'import_id') - - if Fixnum === import_ids.first - existing = existing.where('cast(value as int) in (?)', import_ids) - else - existing = existing.where('value in (?)', import_ids) - end + existing = existing.where('value in (?)', import_ids.map(&:to_s)) if existing.count == import_ids.length # puts "Skipping #{import_ids.length} already imported #{type}"