We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent fcd6037 commit cef0425Copy full SHA for cef0425
django_mongodb/compiler.py
@@ -435,11 +435,17 @@ def project_field(column):
435
436
@cached_property
437
def collection_name(self):
438
- base_table = next(
439
- v
440
- for k, v in self.query.alias_map.items()
441
- if isinstance(v, BaseTable) and self.query.alias_refcount[k]
442
- )
+ try:
+ base_table = next(
+ v
+ for k, v in self.query.alias_map.items()
+ if isinstance(v, BaseTable) and self.query.alias_refcount[k]
443
+ )
444
+ except StopIteration:
445
+ query = self.query_class(self)
446
+ query.aggregation_pipeline = [{"$facet": {"__null": []}}]
447
+ self.subqueries.insert(0, query)
448
+ return "__null"
449
return base_table.table_alias or base_table.table_name
450
451
0 commit comments