MCPcopy
hub / github.com/sqlalchemy/sqlalchemy / first

Method first

lib/sqlalchemy/ext/baked.py:439–453  ·  view source on GitHub ↗

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

(self)

Source from the content-addressed store, hash-verified

437 return None
438
439 def first(self):
440 """Return the first row.
441
442 Equivalent to :meth:`_query.Query.first`.
443
444 """
445
446 bq = self.bq.with_criteria(lambda q: q.slice(0, 1))
447 return (
448 bq.for_session(self.session)
449 .params(self._params)
450 ._using_post_criteria(self._post_criteria)
451 ._iter()
452 .first()
453 )
454
455 def one(self):
456 """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