-
Notifications
You must be signed in to change notification settings - Fork 16
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
if the value is 0 (int) it will be set to None #73
Comments
Hello @sla-te , Can you please share an example for how to reproduce your issue? There is already one test for that situation your mentioning and it seems to be adding 0 as expected. |
@VMRuiz I will extract the scenario where it happens in my logic and update this post with it. |
Values are passed wrapped inside an iterator |
@VMRuiz I fixed that by just changing The test passes due to the |
Ok, is this what you mean?
In that case, yes. It looks like the check could be problematic. I'm not sure which solution is better: processed_value = self._process_input_value(field_name, value)
if processed_value is not None:
self._values.setdefault(field_name, [])
self._values[field_name] += arg_to_iter(processed_value) or processed_value = arg_to_iter(self._process_input_value(field_name, value))
if processed_value:
self._values.setdefault(field_name, [])
self._values[field_name] += processed_value First one will ignore cc. @wRAR |
Yes, pretty much any combination, that would involve unwrapping the the iterable inside the |
@VMRuiz, consider this processed_value = self._process_input_value(field_name, value)
values = [v for v in arg_to_iter(processed_value) if v is not None]
if values:
self._values.setdefault(field_name, [])
self._values[field_name] += values |
https://github.com/scrapy/itemloaders/blob/68e8701432bd8bebb990668a8938145477f60d37/itemloaders/__init__.py#L205C25-L205C25 will not set the value to 0 in case 0 is being passed, instead the value will be set to NoneType.
The text was updated successfully, but these errors were encountered: