Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

CSV Bulk Import multiple $duplicateChecks allow combining conditions #2542

Open
Zauberfisch opened this issue Oct 15, 2013 · 3 comments
Open

Comments

@Zauberfisch
Copy link
Contributor

currently the $duplicateChecks check as OR, so lets say you have:

public $duplicateChecks = array('ID' => 'ID', 'Title' => 'Title');

this would basically do a SQL: WHERE ID = $ID OR Title = $Title
but a OR might not always be the desired condition.

lets take a product import:

"Category","Title","Price"
"Food","Unicorn Meat","42"
"Specials","Unicorn Horn","1337"
"Specials","A scale of Zauberfisch","invaluable"
"Food","RandomName","21"
"Specials","RandomName","42"

so, RandomName in Food might be something different than RandomName in Specials, therefor I need to check WHERE Category = $Category AND Title = $Title

but with the current implementation just using

 public $duplicateChecks = array('Category' => 'Category', 'Title' => 'Title');

would not work here, because it would consider a Unicorn Horn a duplicate of A scale of Zauberfisch, which clearly is wrong.

I can workaround using a callback on a single value (eg. Title) and perform both checks in that callback, but shouldn't the CsvBulkLoader be able to to handle this usecase?

what are your thoughts on that? If I get some input and we agree on a way to implement it, I am happy to do it.

@Zauberfisch
Copy link
Contributor Author

after some conversation in IRC, I think it stands to consider if this even still has a reason to exist.

considering how easy doing this with a datalist is now (->filterAny(array('Title' => $title)))

another point to deprecate this is that it is not consistent and misleading,
I just discovered that 'Name' => 'Title' actually completely ignores Name and only uses Title on both the CSV data as well as in the Database
only when using 'Name' => callback then the Name is used

@Zauberfisch
Copy link
Contributor Author

@dhensby
Copy link
Contributor

dhensby commented Mar 19, 2018

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

6 participants