MCPcopy
hub / github.com/sqlalchemy/sqlalchemy / setup

Method setup

lib/sqlalchemy/ext/baked.py:497–524  ·  view source on GitHub ↗
(query)

Source from the content-addressed store, hash-verified

495 _get_clause, _get_params = mapper._get_clause
496
497 def setup(query):
498 _lcl_get_clause = _get_clause
499 q = query._clone()
500 q._get_condition()
501 q._order_by = None
502
503 # None present in ident - turn those comparisons
504 # into "IS NULL"
505 if None in primary_key_identity:
506 nones = {
507 _get_params[col].key
508 for col, value in zip(
509 mapper.primary_key, primary_key_identity
510 )
511 if value is None
512 }
513 _lcl_get_clause = sql_util.adapt_criterion_to_null(
514 _lcl_get_clause, nones
515 )
516
517 # TODO: can mapper._get_clause be pre-adapted?
518 q._where_criteria = (
519 sql_util._deep_annotate(_lcl_get_clause, {"_orm_adapt": True}),
520 )
521
522 for fn in self._post_criteria:
523 q = fn(q)
524 return q
525
526 # cache the query against a key that includes
527 # which positions in the primary key are NULL

Callers

nothing calls this directly

Calls 2

_get_conditionMethod · 0.80
_cloneMethod · 0.45

Tested by

no test coverage detected