MCPcopy
hub / github.com/sqlalchemy/sqlalchemy / scalar

Method scalar

lib/sqlalchemy/ext/baked.py:423–437  ·  view source on GitHub ↗

Return the first element of the first result or None if no rows present. If multiple rows are returned, raises MultipleResultsFound. Equivalent to :meth:`_query.Query.scalar`.

(self)

Source from the content-addressed store, hash-verified

421 return bq.for_session(self.session).params(self._params).scalar()
422
423 def scalar(self):
424 """Return the first element of the first result or None
425 if no rows present. If multiple rows are returned,
426 raises MultipleResultsFound.
427
428 Equivalent to :meth:`_query.Query.scalar`.
429
430 """
431 try:
432 ret = self.one()
433 if not isinstance(ret, collections_abc.Sequence):
434 return ret
435 return ret[0]
436 except orm_exc.NoResultFound:
437 return None
438
439 def first(self):
440 """Return the first row.

Callers 1

countMethod · 0.45

Calls 1

oneMethod · 0.95

Tested by

no test coverage detected