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
| 1535 | |
| 1536 | @inspection._self_inspects |
| 1537 | class Bundle( |
| 1538 | ORMColumnsClauseRole[_T], |
| 1539 | SupportsCloneAnnotations, |
| 1540 | MemoizedHasCacheKey, |
| 1541 | inspection.Inspectable["Bundle[_T]"], |
| 1542 | InspectionAttr, |
| 1543 | ): |
| 1544 | """A grouping of SQL expressions that are returned by a :class:`.Query` |
| 1545 | under one namespace. |
| 1546 | |
| 1547 | The :class:`.Bundle` essentially allows nesting of the tuple-based |
| 1548 | results returned by a column-oriented :class:`_query.Query` object. |
| 1549 | It also |
| 1550 | is extensible via simple subclassing, where the primary capability |
| 1551 | to override is that of how the set of expressions should be returned, |
| 1552 | allowing post-processing as well as custom return types, without |
| 1553 | involving ORM identity-mapped classes. |
| 1554 | |
| 1555 | .. seealso:: |
| 1556 | |
| 1557 | :ref:`bundles` |
| 1558 | |
| 1559 | |
| 1560 | """ |
| 1561 | |
| 1562 | single_entity = False |
| 1563 | """If True, queries for a single Bundle will be returned as a single |
| 1564 | entity, rather than an element within a keyed tuple.""" |
| 1565 | |
| 1566 | is_clause_element = False |
| 1567 | |
| 1568 | is_mapper = False |
| 1569 | |
| 1570 | is_aliased_class = False |
| 1571 | |
| 1572 | is_bundle = True |
| 1573 | |
| 1574 | _propagate_attrs: _PropagateAttrsType = util.immutabledict() |
| 1575 | |
| 1576 | proxy_set = util.EMPTY_SET |
| 1577 | |
| 1578 | exprs: List[_ColumnsClauseElement] |
| 1579 | |
| 1580 | def __init__( |
| 1581 | self, name: str, *exprs: _ColumnExpressionArgument[Any], **kw: Any |
| 1582 | ): |
| 1583 | r"""Construct a new :class:`.Bundle`. |
| 1584 | |
| 1585 | e.g.:: |
| 1586 | |
| 1587 | bn = Bundle("mybundle", MyClass.x, MyClass.y) |
| 1588 | |
| 1589 | for row in session.query(bn).filter(bn.c.x == 5).filter(bn.c.y == 4): |
| 1590 | print(row.mybundle.x, row.mybundle.y) |
| 1591 | |
| 1592 | :param name: name of the bundle. |
| 1593 | :param \*exprs: columns or SQL expressions comprising the bundle. |
| 1594 | :param single_entity=False: if True, rows for this :class:`.Bundle` |
no outgoing calls