MCPcopy
hub / github.com/sqlalchemy/sqlalchemy / visit_alias

Method visit_alias

lib/sqlalchemy/sql/compiler.py:4461–4560  ·  view source on GitHub ↗
(
        self,
        alias,
        asfrom=False,
        ashint=False,
        iscrud=False,
        fromhints=None,
        subquery=False,
        lateral=False,
        enclosing_alias=None,
        from_linter=None,
        within_tstring=False,
        **kwargs,
    )

Source from the content-addressed store, hash-verified

4459 return self.visit_column(element, **kw)
4460
4461 def visit_alias(
4462 self,
4463 alias,
4464 asfrom=False,
4465 ashint=False,
4466 iscrud=False,
4467 fromhints=None,
4468 subquery=False,
4469 lateral=False,
4470 enclosing_alias=None,
4471 from_linter=None,
4472 within_tstring=False,
4473 **kwargs,
4474 ):
4475 if lateral:
4476 if "enclosing_lateral" not in kwargs:
4477 # if lateral is set and enclosing_lateral is not
4478 # present, we assume we are being called directly
4479 # from visit_lateral() and we need to set enclosing_lateral.
4480 assert alias._is_lateral
4481 kwargs["enclosing_lateral"] = alias
4482
4483 # for lateral objects, we track a second from_linter that is...
4484 # lateral! to the level above us.
4485 if (
4486 from_linter
4487 and "lateral_from_linter" not in kwargs
4488 and "enclosing_lateral" in kwargs
4489 ):
4490 kwargs["lateral_from_linter"] = from_linter
4491
4492 if enclosing_alias is not None and enclosing_alias.element is alias:
4493 inner = alias.element._compiler_dispatch(
4494 self,
4495 asfrom=asfrom,
4496 ashint=ashint,
4497 iscrud=iscrud,
4498 fromhints=fromhints,
4499 lateral=lateral,
4500 enclosing_alias=alias,
4501 **kwargs,
4502 )
4503 if subquery and (asfrom or lateral):
4504 inner = "(%s)" % (inner,)
4505 return inner
4506 else:
4507 kwargs["enclosing_alias"] = alias
4508
4509 if asfrom or ashint or within_tstring:
4510 if isinstance(alias.name, elements._truncated_label):
4511 alias_name = self._truncated_identifier("alias", alias.name)
4512 else:
4513 alias_name = alias.name
4514
4515 if ashint:
4516 return self.preparer.format_alias(alias, alias_name)
4517 elif asfrom or within_tstring:
4518 if from_linter:

Callers 4

visit_subqueryMethod · 0.95
visit_lateralMethod · 0.95
visit_tablesampleMethod · 0.95

Calls 9

_truncated_identifierMethod · 0.95
format_from_hint_textMethod · 0.95
format_aliasMethod · 0.80
_de_cloneMethod · 0.80
_compiler_dispatchMethod · 0.45
joinMethod · 0.45
quoteMethod · 0.45
processMethod · 0.45

Tested by

no test coverage detected