mirror of
https://github.com/django/django.git
synced 2025-10-24 06:06:09 +00:00
Fixed #27332 -- Added FilteredRelation API for conditional join (ON clause) support.
Thanks Anssi Kääriäinen for contributing to the patch.
This commit is contained in:
committed by
Tim Graham
parent
3f9d85d95c
commit
01d440fa1e
@@ -53,15 +53,31 @@ class StartsWithRelation(models.ForeignObject):
|
||||
def get_joining_columns(self, reverse_join=False):
|
||||
return ()
|
||||
|
||||
def get_path_info(self):
|
||||
def get_path_info(self, filtered_relation=None):
|
||||
to_opts = self.remote_field.model._meta
|
||||
from_opts = self.model._meta
|
||||
return [PathInfo(from_opts, to_opts, (to_opts.pk,), self, False, False)]
|
||||
return [PathInfo(
|
||||
from_opts=from_opts,
|
||||
to_opts=to_opts,
|
||||
target_fields=(to_opts.pk,),
|
||||
join_field=self,
|
||||
m2m=False,
|
||||
direct=False,
|
||||
filtered_relation=filtered_relation,
|
||||
)]
|
||||
|
||||
def get_reverse_path_info(self):
|
||||
def get_reverse_path_info(self, filtered_relation=None):
|
||||
to_opts = self.model._meta
|
||||
from_opts = self.remote_field.model._meta
|
||||
return [PathInfo(from_opts, to_opts, (to_opts.pk,), self.remote_field, False, False)]
|
||||
return [PathInfo(
|
||||
from_opts=from_opts,
|
||||
to_opts=to_opts,
|
||||
target_fields=(to_opts.pk,),
|
||||
join_field=self.remote_field,
|
||||
m2m=False,
|
||||
direct=False,
|
||||
filtered_relation=filtered_relation,
|
||||
)]
|
||||
|
||||
def contribute_to_class(self, cls, name, private_only=False):
|
||||
super().contribute_to_class(cls, name, private_only)
|
||||
|
||||
Reference in New Issue
Block a user