Given the following input rows
id,type,title
1,blog,This is a blog post
2,page,This is a basic page
3,news,This is a news article
4,testimonial,This is a testimonial
...
I am trying to use SkipOnValue so that all rows where the type is news or blog are migrated ("skip row if type not in [blog,news]"). I figured the following configuration would work:
type:
-
plugin: skip_on_value
not_equals: true
source: type
method: row
value:
- "blog"
- "news"
It doens't. The problem seems to be that SkipOnValue::compare is called against the import row for *each* of the configured values. So when the first row is processed, the source value "blog" is checked against the first configured value "blog". Since this comparison (not equals) returns FALSE, processing continues, and SkipOnValue goes on to compare the source value against the second configured value ("news"). Comparing ("not equals") the source value "blog" with configured value "news" *does* yield TRUE, and the row is skipped, even though the source value is in the list of configured values that should not be skipped.
Using this approach, it does not seem possible to use SkipOnValue to whitelist more than one value for which the row should not be skipped? Attached is a patch that alters the plugin so that it behaves like in_array or !in_array when multiple values are configured.
Comment | File | Size | Author |
---|---|---|---|
#5 | 2959775-1-5-interdiff.txt | 2.59 KB | gnuget |
#5 | 2959775-5-tests-only.patch | 1.59 KB | gnuget |
#5 | 2959775-5.patch | 3.37 KB | gnuget |
migrate_plus-skip_on_value.patch | 1022 bytes | mr.baileys |
Comments
Comment #2
mr.baileysThe fact that tests pass with this patch means that additional test coverage is required.
Comment #3
heddnNW because needs tests :)
Comment #4
heddnIs this a duplicate of #2948186: SkipOnValue not_equals fails when list?
Comment #5
gnugetI faced this today so I decided to write the tests and I added support when the method is
process
instead ofrow
Patch, interdiff and only-test patch attached.
Comment #7
gnugetComment #9
heddn