The full SELECT statement represented by this Query. The statement by default will not have disambiguating labels applied to the construct unless with_labels(True) is called first.
(self)
| 495 | |
| 496 | @property |
| 497 | def statement(self) -> Union[Select[_T], FromStatement[_T], UpdateBase]: |
| 498 | """The full SELECT statement represented by this Query. |
| 499 | |
| 500 | The statement by default will not have disambiguating labels |
| 501 | applied to the construct unless with_labels(True) is called |
| 502 | first. |
| 503 | |
| 504 | """ |
| 505 | |
| 506 | # .statement can return the direct future.Select() construct here, as |
| 507 | # long as we are not using subsequent adaption features that |
| 508 | # are made against raw entities, e.g. from_self(), with_polymorphic(), |
| 509 | # select_entity_from(). If these features are being used, then |
| 510 | # the Select() we return will not have the correct .selected_columns |
| 511 | # collection and will not embed in subsequent queries correctly. |
| 512 | # We could find a way to make this collection "correct", however |
| 513 | # this would not be too different from doing the full compile as |
| 514 | # we are doing in any case, the Select() would still not have the |
| 515 | # proper state for other attributes like whereclause, order_by, |
| 516 | # and these features are all deprecated in any case. |
| 517 | # |
| 518 | # for these reasons, Query is not a Select, it remains an ORM |
| 519 | # object for which __clause_element__() must be called in order for |
| 520 | # it to provide a real expression object. |
| 521 | # |
| 522 | # from there, it starts to look much like Query itself won't be |
| 523 | # passed into the execute process and won't generate its own cache |
| 524 | # key; this will all occur in terms of the ORM-enabled Select. |
| 525 | stmt: Union[Select[_T], FromStatement[_T], UpdateBase] |
| 526 | |
| 527 | if not self._compile_options._set_base_alias: |
| 528 | # if we don't have legacy top level aliasing features in use |
| 529 | # then convert to a future select() directly |
| 530 | stmt = self._statement_20(for_statement=True) |
| 531 | else: |
| 532 | stmt = self._compile_state(for_statement=True).statement |
| 533 | |
| 534 | if self._params: |
| 535 | stmt = stmt.params(self._params) |
| 536 | |
| 537 | return stmt |
| 538 | |
| 539 | def _final_statement(self, legacy_query_style: bool = True) -> Select[Any]: |
| 540 | """Return the 'final' SELECT statement for this :class:`.Query`. |
nothing calls this directly
no test coverage detected