MCPcopy
hub / github.com/sqlalchemy/sqlalchemy / tuples

Method tuples

lib/sqlalchemy/orm/query.py:312–339  ·  view source on GitHub ↗

return a tuple-typed form of this :class:`.Query`. This method invokes the :meth:`.Query.only_return_tuples` method with a value of ``True``, which by itself ensures that this :class:`.Query` will always return :class:`.Row` objects, even if the query is made against

(self: Query[_O])

Source from the content-addressed store, hash-verified

310 "now behaves like a tuple and can unpack types directly.",
311 )
312 def tuples(self: Query[_O]) -> Query[Tuple[_O]]:
313 """return a tuple-typed form of this :class:`.Query`.
314
315 This method invokes the :meth:`.Query.only_return_tuples`
316 method with a value of ``True``, which by itself ensures that this
317 :class:`.Query` will always return :class:`.Row` objects, even
318 if the query is made against a single entity. It then also
319 at the typing level will return a "typed" query, if possible,
320 that will type result rows as ``Tuple`` objects with typed
321 elements.
322
323 This method can be compared to the :meth:`.Result.tuples` method,
324 which returns "self", but from a typing perspective returns an object
325 that will yield typed ``Tuple`` objects for results. Typing
326 takes effect only if this :class:`.Query` object is a typed
327 query object already.
328
329 .. versionadded:: 2.0
330
331 .. seealso::
332
333 :ref:`change_10635` - describes a migration path from this
334 workaround for SQLAlchemy 2.1.
335
336 :meth:`.Result.tuples` - v2 equivalent method.
337
338 """
339 return self.only_return_tuples(True) # type: ignore
340
341 def _entity_from_pre_ent_zero(self) -> Optional[_InternalEntityType[Any]]:
342 if not self._raw_columns:

Calls 1

only_return_tuplesMethod · 0.95

Tested by 4

test_result_tuplesMethod · 0.36
test_tuples_plus_baseMethod · 0.36