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

Always use specific null values for fixed fields #2605

Merged
merged 5 commits into from
Jun 21, 2017
Merged

Always use specific null values for fixed fields #2605

merged 5 commits into from
Jun 21, 2017

Conversation

sampsyo
Copy link
Member

@sampsyo sampsyo commented Jun 20, 2017

This came out of an attempt to address the mysterious testing problems from #2563 and turned into a big old debacle. As it turns out, the problem came from calling Item.from_path and getting None for fields that weren't filled out by the MediaFile data. Everywhere else, we fill out these fixed attributes with the special null value for the field's type, so it's actually pretty confusing that these could mysteriously become None. I think it will be saner all around if we enforce this universally.

There were two possible fixes: one in __getitem__ to check for missing values and one that set all the missing values in the constructor. I opted for the former because it has a smaller footprint, but the latter might have slightly better performance (depending on the ratio of constructions to lookups).

There were a few tests that implicitly depended on the old behavior, which I've fixed. I've also fixed a couple of fields that were relying implicitly on the old sometimes-None, sometimes-not behavior to explicitly allow the fields to be None. (Namely, artpath and initial_key.)

This came out of an attempt to address the mysterious testing problems from
PR #2563 and turned into a big old debacle. As it turns out, the problem came
from calling Item.from_path and getting None for fields that weren't filled
out by the MediaFile data. Everywhere else, we fill out these fixed attributes
with the special null value for the field's type, so it's actually pretty
confusing that these could mysteriously become None. I think it will be saner
all around if we enforce this universally.

There were two possible fixes: one in __getitem__ to check for missing values
and one that set all the missing values in the constructor. I opted for the
former because it has a smaller footprint, but the latter might have slightly
better performance (depending on the ratio of constructions to lookups).
These were written to incidentally depend on Nones; the behavior they're
actually testing doesn't really have anything to say about None-ness.
We really want `Album.artpath` to be None sometimes, and this was relying on
some accidental dbcore behavior before. Now, we explicitly mark the field as
nullable: it may be a path, or it may be None to indicate that there is no
art.
Fixes a `modify` test, of all things.
@sampsyo sampsyo merged commit 5ca43c3 into master Jun 21, 2017
sampsyo added a commit that referenced this pull request Jun 21, 2017
@arcresu arcresu deleted the fixednone branch April 24, 2019 05:03
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant