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)
| 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. |