[Patchew-devel] [PATCH 06/12] models: create Result model
Fam Zheng
famz at redhat.com
Tue May 22 15:14:42 UTC 2018
On Tue, 05/22 16:57, Paolo Bonzini wrote:
> On 22/05/2018 10:11, Fam Zheng wrote:
> > On Tue, 05/22 08:57, Paolo Bonzini wrote:
> >> @@ -58,6 +140,7 @@ class Project(models.Model):
> >> top project which has
> >> parent_project=NULL""")
> >> maintainers = models.ManyToManyField(User, blank=True)
> >> + results = models.ManyToManyField(Result, blank=True)
> >>
> >> def __str__(self):
> >> return self.name
> >> @@ -319,6 +402,7 @@ class Message(models.Model):
> >> num_patches = models.IntegerField(null=False, default=-1, blank=True)
> >>
> >> objects = MessageManager()
> >> + results = models.ManyToManyField(Result, blank=True)
> > Why ManyToMany relationship? A Result entry belongs to exactly one Project or
> > Message, just like Property, no?
>
> Yes, however I wanted to avoid the same issue like we have with
> properties, where we need two classes ProjectProperty or MessageProperty
> for basically the same model. And if I add a OneToManyField, I'll have
> two database fields in the api_result table (for the project_id and the
> message_id).
>
> It's not great but I don't have a better idea, it's the best I could do
> (start) on a plane without StackOverflow. :) That's also why the series
> is RFC.
Maybe we could create a dummy Message for each Project as a host of its results,
so we can forward the Project.results property to the Message entry? (The same
applies to ProjectProperty). It's also quite ugly, but perhaps slighly more
straightforward than this.
Fam
More information about the Patchew-devel
mailing list