MCPcopy Create free account
hub / github.com/sqlalchemy/sqlalchemy / first

Method first

lib/sqlalchemy/ext/baked.py:450–464  ·  view source on GitHub ↗

Return the first row. Equivalent to :meth:`_query.Query.first`.

(self)

Source from the content-addressed store, hash-verified

448 return None
449
450 def first(self):
451 """Return the first row.
452
453 Equivalent to :meth:`_query.Query.first`.
454
455 """
456
457 bq = self.bq.with_criteria(lambda q: q.slice(0, 1))
458 return (
459 bq.for_session(self.session)
460 .params(self._params)
461 ._using_post_criteria(self._post_criteria)
462 ._iter()
463 .first()
464 )
465
466 def one(self):
467 """Return exactly one result or raise an exception.

Callers

nothing calls this directly

Calls 6

with_criteriaMethod · 0.80
_using_post_criteriaMethod · 0.80
for_sessionMethod · 0.80
sliceMethod · 0.45
_iterMethod · 0.45
paramsMethod · 0.45

Tested by

no test coverage detected