A grouping of SQL expressions that are returned by a :class:`.Query` under one namespace. The :class:`.Bundle` essentially allows nesting of the tuple-based results returned by a column-oriented :class:`_query.Query` object. It also is extensible via simple subclassing, where th
| 1553 | |
| 1554 | @inspection._self_inspects |
| 1555 | class Bundle( |
| 1556 | ORMColumnsClauseRole[_T], |
| 1557 | SupportsCloneAnnotations, |
| 1558 | MemoizedHasCacheKey, |
| 1559 | inspection.Inspectable["Bundle[_T]"], |
| 1560 | InspectionAttr, |
| 1561 | ): |
| 1562 | """A grouping of SQL expressions that are returned by a :class:`.Query` |
| 1563 | under one namespace. |
| 1564 | |
| 1565 | The :class:`.Bundle` essentially allows nesting of the tuple-based |
| 1566 | results returned by a column-oriented :class:`_query.Query` object. |
| 1567 | It also |
| 1568 | is extensible via simple subclassing, where the primary capability |
| 1569 | to override is that of how the set of expressions should be returned, |
| 1570 | allowing post-processing as well as custom return types, without |
| 1571 | involving ORM identity-mapped classes. |
| 1572 | |
| 1573 | .. seealso:: |
| 1574 | |
| 1575 | :ref:`bundles` |
| 1576 | |
| 1577 | :class:`.DictBundle` |
| 1578 | |
| 1579 | """ |
| 1580 | |
| 1581 | single_entity = False |
| 1582 | """If True, queries for a single Bundle will be returned as a single |
| 1583 | entity, rather than an element within a keyed tuple.""" |
| 1584 | |
| 1585 | is_clause_element = False |
| 1586 | |
| 1587 | is_mapper = False |
| 1588 | |
| 1589 | is_aliased_class = False |
| 1590 | |
| 1591 | is_bundle = True |
| 1592 | |
| 1593 | _propagate_attrs: _PropagateAttrsType = util.immutabledict() |
| 1594 | |
| 1595 | proxy_set = util.EMPTY_SET |
| 1596 | |
| 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. |
no outgoing calls