MCPcopy
hub / github.com/sqlalchemy/sqlalchemy / __init__

Method __init__

lib/sqlalchemy/orm/util.py:1599–1631  ·  view source on GitHub ↗

r"""Construct a new :class:`.Bundle`. e.g.:: bn = Bundle("mybundle", MyClass.x, MyClass.y) for row in session.query(bn).filter(bn.c.x == 5).filter(bn.c.y == 4): print(row.mybundle.x, row.mybundle.y) :param name: name of the bundle.

(
        self, name: str, *exprs: _ColumnExpressionArgument[Any], **kw: Any
    )

Source from the content-addressed store, hash-verified

1597 exprs: List[_ColumnsClauseElement]
1598
1599 def __init__(
1600 self, name: str, *exprs: _ColumnExpressionArgument[Any], **kw: Any
1601 ) -> None:
1602 r"""Construct a new :class:`.Bundle`.
1603
1604 e.g.::
1605
1606 bn = Bundle("mybundle", MyClass.x, MyClass.y)
1607
1608 for row in session.query(bn).filter(bn.c.x == 5).filter(bn.c.y == 4):
1609 print(row.mybundle.x, row.mybundle.y)
1610
1611 :param name: name of the bundle.
1612 :param \*exprs: columns or SQL expressions comprising the bundle.
1613 :param single_entity=False: if True, rows for this :class:`.Bundle`
1614 can be returned as a "single entity" outside of any enclosing tuple
1615 in the same manner as a mapped entity.
1616
1617 """ # noqa: E501
1618 self.name = self._label = name
1619 coerced_exprs = [
1620 coercions.expect(
1621 roles.ColumnsClauseRole, expr, apply_propagate_attrs=self
1622 )
1623 for expr in exprs
1624 ]
1625 self.exprs = coerced_exprs
1626
1627 self.c = self.columns = WriteableColumnCollection(
1628 (getattr(col, "key", col._label), col)
1629 for col in [e._annotations.get("bundle", e) for e in coerced_exprs]
1630 ).as_readonly()
1631 self.single_entity = kw.pop("single_entity", self.single_entity)
1632
1633 def _gen_cache_key(
1634 self, anon_map: anon_map, bindparams: List[BindParameter[Any]]

Callers 8

create_for_statementMethod · 0.45
_setup_for_orm_updateMethod · 0.45
create_for_statementMethod · 0.45
__init__Method · 0.45
__init__Method · 0.45
__init__Method · 0.45
__init__Method · 0.45

Calls 4

as_readonlyMethod · 0.45
getMethod · 0.45
popMethod · 0.45

Tested by

no test coverage detected