You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
A lot of the time we have to add custom code to validate loaded data before copying it. A common use case is to ignore duplicate lines but still continue the import.
A subscriber on ImportEvents::POST_LOAD would then execute an UPDATE on temporary table to set the "valid" field to false on failing rows. In case of validation error, when on_invalid is set to "ignore", it would add logs "Unique code validation constraint failed. Skipping duplicate my_resource_name (code: 12345) at lines 4, 5, 6" and import would continue without copying invalid lines. If on_invalid is set to "abort", it would stop the import without copying the data.
Other validation constraints could be added, like format validation (regex), etc.
A simpler option would be to skip the validation config, instead adding an option to run an arbitrary SQL query on post_load to set the "valid" flag.
The text was updated successfully, but these errors were encountered:
Hello, is this piece of code from the documentation? Because there is no indication that we can produce a custom configuration especially with "post_load".
Hello, is this piece of code from the documentation? Because there is no indication that we can produce a custom configuration especially with "post_load".
A lot of the time we have to add custom code to validate loaded data before copying it. A common use case is to ignore duplicate lines but still continue the import.
It could be set like this:
A subscriber on
ImportEvents::POST_LOAD
would then execute an UPDATE on temporary table to set the "valid" field tofalse
on failing rows. In case of validation error, when on_invalid is set to "ignore", it would add logs "Unique code validation constraint failed. Skipping duplicate my_resource_name (code: 12345) at lines 4, 5, 6" and import would continue without copying invalid lines. If on_invalid is set to "abort", it would stop the import without copying the data.Other validation constraints could be added, like format validation (regex), etc.
A simpler option would be to skip the validation config, instead adding an option to run an arbitrary SQL query on post_load to set the "valid" flag.
The text was updated successfully, but these errors were encountered: