Compare Datasets error when Input B has no records

Describe the problem/error/question

I am syncing two databases, Input A is Zoho CRM with a few records. Input B is MySQL and it has 0 records. In this use case, I am attempting to populate InputB from Input A. I am getting an error: “Problem in node ‘Compare Datasets‘ Field ‘crmId’ is not present in any of items in ‘Input B’”

In my setup, I am wanting to use the id from ZohoCRM (Input A) as they key (which I refer to as crmId in a ‘Set’ node). I also have a field named crmId in MySQL (Input B) to serve as the key. Obviously there are no key values coming into the Compare Datasets node from Input B in this scenario. How can I cause the Compare Datasets to handle this situation?

When I have at least 1 record in both systems, the Compare Datasets node works great - even if 100% of MySQL records do not have a crmId value. They will be considered as “B only” records and be created in Zoho, which is what I am after. The problem arises when the data incoming from one of the inputs is null or empty. I assume the same problem would occur if Input A had no records and Input B did.

I have attempted to turn on the ‘Always Output Data’ setting on MySQL to allow an empty object through. I tried using a ternary to set an empty string and also a fake crmId when the incoming value does not exist. I’m not yet getting the desired result, where all records from Input A are detected as new and inserted into MySQL in subsequent nodes.

Information on your n8n setup

  • n8n version: 0.221.2
  • Database (default: SQLite):
  • n8n EXECUTIONS_PROCESS setting (default: own, main):
  • Running n8n via (Docker, npm, n8n cloud, desktop app): cloud
  • Operating system:

Current idea is to create a “fake” item when MySQL returns 0 records so that the Compare Datasets node has something to work with, but the fake record would intentionally be missing a field that is required later on in the workflow so that it fails to sync out to anywhere…

Hi @hndmn, to be honest I never know what’s expected or not with this node, so am not quite sure how to respond here :see_no_evil:

I shall add this to our bug tracker for a closer look by the product and engineering team.

Thanks @MutedJam - we are quickly becoming experts on this node. It’s going to be a core component to one of our main workflows. Besides this issue (maybe it’s a feature and not a bug?) we are also seeing some odd behavior after the Compare Datasets node where the “winning” record is updated with data from the incorrect record. This may well be user error, and we are still testing out ideas, but we patterned it off of the template at Two way sync Pipedrive and MySQL | n8n workflow template. More on that (perhaps another question entirely) soon with some examples.

1 Like

Looks like the original issue is indeed a bug. We’ll post an update once this is fixed.

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.