When using multiple mappings as unique, provide an option to search for an existing entity based on all of them

Created on 5 August 2022, over 2 years ago
Updated 28 January 2025, 27 days ago

Problem/Motivation

My feed is creating content that is identified (as unique) by 2 fields, but just 1 is used in the mapping, resulting in multiple Updates of the same content item for different inputs/fields.

Steps to reproduce

  1. Create a content type "Account" and add 2 fields: name, address
  2. Set name and address fields to be unique (using unique_content_field_validation module).
  3. Create a feed type processing nodes of type Account, with settings: Insert new content items, Update existing content items.
  4. Set Mapping settings:
  5. - Context = account_responses
  6. - New Json source = account.name -> target: field_name
  7. - New Json source = account.address -> target: field_address

Create and import a feed that produces this input:

{
    "account_responses": [
        {
            "account": {
                "name": "xxx",
                "address": "yyy"
            },
            "balance": {
                "denom": "aaa",
                "amount": "111"
            }
        },
        {
            "account": {
                "name": "xxx",
                "address": "zzz"
            },
            "balance": {
                "denom": "bbb",
                "amount": "222"
            }
        }
    ],
    "other_stuff": {}
} 

Get this Output:
Created 1 Response (node 1: name = www, address = yyy)
Updated 1 Response (node 1: name = www, address = zzz)

So you are left with only 1 content item (the second in the input).

Proposed resolution

I'm filing this issue as a bug since by default the module UI allows to mark multiple targets to be unique.
In that case, we should check for a join/concatenation of the values.
Is it even possible?

Remaining tasks

User interface changes

API changes

Data model changes

Feature request
Status

Active

Component

Code

Created by

🇮🇹Italy kopeboy Milan

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

Not all content is available!

It's likely this issue predates Contrib.social: some issue and comment data are missing.

  • 🇺🇸United States josh.stewart Lexington, KY

    I ran into this recently so I went ahead and wrote a patch that works specifically for our use case. I have not ran any of the tests but we needed something quick and dirty to solve this. I know it's probably not the best solution out there but this did work for us in a pinch if it helps someone else that runs into this.

    I was able to combine two fields (both plain text fields- title and another field) to query easily the ones we needed and skip over them since we had previously run the feeds and were overwriting multiple nodes multiple times due to collisions in either one of the fields chosen as unique.

Production build 0.71.5 2024