Closed (fixed)
Project:
Feeds
Version:
8.x-3.x-dev
Component:
Code
Priority:
Normal
Category:
Feature request
Assigned:
Unassigned
Issue tags:
Reporter:
Created:
23 Oct 2017 at 19:04 UTC
Updated:
6 Apr 2020 at 14:19 UTC
Jump to comment: Most recent, Most recent file
Comments
Comment #2
megachrizPatches are welcome.
Comment #3
megachrizTo be able to mark a field as unique, on the FeedsTarget plugin
markPropertyUnique()must be called on the field target definition for a specified field column. See \Drupal\feeds\Feeds\Target\StringTarget for an example.Comment #4
boinkster commentedHere's a patch for number and integer fields. I didn't include list types figuring they would not likely be unique values. I ran out of time to add testing (maybe later).
Comment #5
megachrizThanks for the patch, @boinkster! Unfortunetaly, it failed to apply. Did you perhaps create the patch against Feeds 8.x-3.0-alpha3? The testbot usually (if not always) tests patches against the latest dev. So in order to create a patch that applies, checkout the latest dev version of Feeds, make your changes, and then create a patch.
Are list number fields not possible to act as unique values? If so, I think the Integer class can keep extending the Number class. Well, even with the current patch Integer can keep extending Number, though it has no direct benefit.
Automated tests are welcome!
Comment #6
karenann commentedHere's an attempt at rerolling this patch.
Comment #7
karenann commentedAfter rerolling this patch and seeing that it passed the 2 tests, I plugged it into my environment and it seemed to work. However, I did not perform rigorous testing.
I did confirm that when setting an integer field as unique in the mapping and importing, any repeated occurrences of that unique field caused the original one to be updated/overwritten with the data of the second occurrence. This is as I would expect.
Thanks, @boinkster and @MegaChriz for the work on this!
Comment #8
caspervoogt commentedI just tested the patch from #6 and it did the trick for me
Comment #9
bwoods commentedAnother confirmation for the patch in #6 - thanks for posting!
Comment #10
caspervoogt commentedComment #11
megachrizCan somebody confirm that list number fields are impossible to act as an unique identifier? Because if it is possible, then there’s no reason to exclude these.
It would be good to have an automated test for this issue. Who wants to write one?
Comment #12
megachrizTagging issue for Global Contrib Weekend Event at SFDUG. Thursday Jan 23.
And briefly updated issue summary.
Comment #13
kris77 commentedThank you so much for patch in #6.
Work for me too.
Thanks @karenann.
Comment #14
megachrizI've tested for which number field types Feeds technically can use them as unique target and I found out that:
Here's a new patch and with some tests. The patch allows "integer", "decimal" and "list_integer" as unique target and it doesn't allow "float" and "list_float" as unique target. No interdiff because I did not start with the previous patch in this issue.
I think this is ready (if it passes tests).
Comment #15
megachrizFixing coding standards. No functional changes were made.
Comment #17
megachrizCommitted #15.
Comment #18
kris77 commentedThank you so much @MegaChriz.
your job is perfect for me.