Skip to content

Commit 09db2d3

Browse files
committed
Expands docs re: one
1 parent 9dadf80 commit 09db2d3

File tree

1 file changed

+9
-6
lines changed

1 file changed

+9
-6
lines changed

postgres.py

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -300,12 +300,15 @@ def one(self, sql, parameters=None, strict=None):
300300
:raises: :py:exc:`~postgres.TooFew` or :py:exc:`~postgres.TooMany`
301301
302302
By default, :py:attr:`strict` ends up evaluating to :py:class:`True`,
303-
in which case we raise :py:exc:`~postgres.TooFew` or
304-
:py:exc:`~postgres.TooMany` if the number of rows returned isn't
305-
exactly one. You can override this behavior per-call with the
306-
:py:attr:`strict` argument here, or globally by passing
307-
:py:attr:`strict_one` to the :py:class:`~postgres.Postgres`
308-
constructor. If you use both, the :py:attr:`strict` argument here wins.
303+
in which case we raise :py:exc:`postgres.TooFew` or
304+
:py:exc:`postgres.TooMany` if the number of rows returned isn't exactly
305+
one (both are subclasses of :py:exc:`postgres.NotOne`). You can
306+
override this behavior per-call with the :py:attr:`strict` argument
307+
here, or globally by passing :py:attr:`strict_one` to the
308+
:py:class:`~postgres.Postgres` constructor. If you use both, the
309+
:py:attr:`strict` argument here wins. If you pass :py:class:`False`
310+
for :py:attr:`strict`, then we return :py:class:`None` if there are no
311+
results, and the first if there is more than one.
309312
310313
>>> row = db.one("SELECT * FROM foo WHERE bar='baz'")
311314
>>> print(row["bar"])

0 commit comments

Comments
 (0)