-
Notifications
You must be signed in to change notification settings - Fork 1.6k
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
data: implement resultspecs dataclass compatibility #7611
base: master
Are you sure you want to change the base?
data: implement resultspecs dataclass compatibility #7611
Conversation
|
||
class ResultSpecMKListMixin: | ||
@staticmethod | ||
def mkdata(fld: Sequence[str] | str, *values): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe just have free function? It doesn't use self, so mixin is possibly an overkill.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah ok, it's used below for inheritance.
I don't understand what downsides are with the current approach and implementation. What future problems could we have if this PR is merged? From a practical standpoint I think the current approach is perfectly fine. |
The PR needs rebase due to conflicts. |
When using I see two options:
I was mostly worried about when a ResultSpec was used in the DB layer, but this codepath will ignore the |
d65e0f7
to
9c4d61d
Compare
More conflicts again. Regarding the risks, resultspecs are used both in DB and data layers, so we need to support both. |
I think that we should have 2 apply functions in I think for the database layer we can simply ignore fields. Most queries return full rows anyway. In the cases where incomplete row is returned we can either change the code to request full row or adjust dataclass to allow null fields. This will not have any user impact because resultspec filtering is only relevant to REST queries and they do resultspec filtering again. See
in master/buildbot/www/rest.py. |
Marking as Draft as I need a chunk of time to take a good look at this and I won't be able until next week. |
9c4d61d
to
e32974a
Compare
@p12tic from what I saw, A better solution would be to change Longer term, I think its a bit dangerous that some DB functions can take a So a second change would be to remove the So to summarize, I'll now:
If you confirm my understanding and agree with my proposal, above:
Depending on my availability, I could take care of the split once I'm done with the move to dataclasses for DB models. |
As mentioned in #7610
resultspecs were only really working with
dict
data. This fix them when used withdataclass
.Change to
includeFields
implements field filtering, which convert a dataclass to a dict.I think this should just not work, but implementation was trivial so I'm still looking for feedback.
Contributor Checklist:
newsfragments
directory (and read theREADME.txt
in that directory)