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
Item loader missing values from base item #3046
Comments
The first issue is a UX issue, but I agree it should be fixed. The second one, I think is more like a bug, as a side-effect of a getter method is wiping valid data in the output. |
Here even if we run the code like this, we get the result -
I think the method get_output_value('field_name'), is not able to print the corresponding values of the key. |
I have added a Bug Fix for this issue. Please have a look into this. @cathalgarvey #3149 |
Fixed by #3819, as @elacuesta mentions in #3897. |
ItemLoaders behave oddly when they get a pre-populated item as an argument and
get_output_value()
gets called for one of the pre-populated fields before callingload_item()
.Check this out:
There are 2 unexpected behaviors in this snippet (at least from my point of view):
1)
loader.get_output_value()
doesn't return the pre-populated values, even though they end up in the final item.It seems to be like this on purpose, though. The
get_output_value()
method only queries the_local_values
defaultdict (here).2) once we call
loader.get_output_value('url')
, that field is not included in theload_item()
result anymore.This one doesn't look right, IMHO.
It happens because when we call
loader.get_output_value('url')
for the first time, such value is not available on_local_values
, and so a new entry in the_local_values
defaultdict will be created with an empty list on it (here). Then, whenloader.load_item()
gets called, these lines overwrite the current value from the internal item because the value returned byget_output_value()
is[]
and notNone
.Any thoughts on this?
The text was updated successfully, but these errors were encountered: