MCPcopy
hub / github.com/django/django / _get_combinator_part_sql

Method _get_combinator_part_sql

django/db/models/sql/compiler.py:634–658  ·  view source on GitHub ↗
(self, compiler)

Source from the content-addressed store, hash-verified

632 return result, params
633
634 def _get_combinator_part_sql(self, compiler):
635 features = self.connection.features
636 # If the columns list is limited, then all combined queries
637 # must have the same columns list. Set the selects defined on
638 # the query on all combined queries, if not already set.
639 selected = self.query.selected
640 if selected is not None and compiler.query.selected is None:
641 compiler.query = compiler.query.clone()
642 compiler.query.set_values(selected)
643 part_sql, part_args = compiler.as_sql(with_col_aliases=True)
644 if compiler.query.combinator:
645 # Wrap in a subquery if wrapping in parentheses isn't
646 # supported.
647 if not features.supports_parentheses_in_compound:
648 part_sql = "SELECT * FROM ({})".format(part_sql)
649 # Add parentheses when combining with compound query if not
650 # already added for all compound queries.
651 elif (
652 self.query.subquery
653 or not features.supports_slicing_ordering_in_compound
654 ):
655 part_sql = "({})".format(part_sql)
656 elif self.query.subquery and features.supports_slicing_ordering_in_compound:
657 part_sql = "({})".format(part_sql)
658 return part_sql, part_args
659
660 def get_qualify_sql(self):
661 where_parts = []

Callers 1

get_combinator_sqlMethod · 0.95

Calls 4

set_valuesMethod · 0.80
cloneMethod · 0.45
as_sqlMethod · 0.45
formatMethod · 0.45

Tested by

no test coverage detected