lib/table_sync/receiving/handler.rb in table_sync-4.2.1 vs lib/table_sync/receiving/handler.rb in table_sync-4.2.2
- old
+ new
@@ -105,9 +105,20 @@
end
if data.uniq { |row| row.slice(*target_keys) }.size != data.size
raise TableSync::DataError.new(data, target_keys, "Duplicate rows found!")
end
+
+ keys_sample = data[0].keys
+ keys_diff = data.each_with_object(Set.new) do |row, set|
+ (row.keys - keys_sample | keys_sample - row.keys).each(&set.method(:add))
+ end
+
+ unless keys_diff.empty?
+ raise TableSync::DataError.new(data, target_keys, <<~MESSAGE)
+ Bad batch structure, check keys: #{keys_diff.to_a}
+ MESSAGE
+ end
end
def perform(config, params)
model = config.model