@@ -367,7 +367,7 @@ def run(self, sql, parameters=None, *a, **kw):
367367 txn .execute (sql , parameters )
368368
369369
370- def one (self , sql , parameters = None , record_type = None , zero = None , \
370+ def one (self , sql , parameters = None , record_type = None , default = None , \
371371 * a , ** kw ):
372372 """Execute a query and return a single result or a default value.
373373
@@ -376,13 +376,13 @@ def one(self, sql, parameters=None, record_type=None, zero=None, \
376376 :type parameters: dict or tuple
377377 :param record_type: the type of record to return
378378 :type record_type: type or string
379- :param zero : the value to return if zero results are found
379+ :param default : the value to return if no results are found
380380 :param a: passed through to
381381 :py:meth:`~postgres.Postgres.get_transaction`
382382 :param kw: passed through to
383383 :py:meth:`~postgres.Postgres.get_transaction`
384- :returns: a single record or value or the value of the :py:attr:`zero`
385- argument
384+ :returns: a single record or value or the value of the
385+ :py:attr:`default` argument
386386 :raises: :py:exc:`~postgres.TooFew` or :py:exc:`~postgres.TooMany`
387387
388388 Use this for the common case where there should only be one record, but
@@ -399,16 +399,16 @@ def one(self, sql, parameters=None, record_type=None, zero=None, \
399399 ...
400400 No blam yet.
401401
402- If you pass :py:attr:`zero ` we'll return that instead of
402+ If you pass :py:attr:`default ` we'll return that instead of
403403 :py:class:`None`:
404404
405- >>> db.one("SELECT * FROM foo WHERE bar='blam'", zero =False)
405+ >>> db.one("SELECT * FROM foo WHERE bar='blam'", default =False)
406406 False
407407
408408 We specifically don't support passing lambdas or other callables for
409- the :py:attr:`zero ` parameter. That gets complicated quickly, and it's
410- easy to just check the return value in the caller and do your extra
411- logic there.
409+ the :py:attr:`default ` parameter. That gets complicated quickly, and
410+ it's easy to just check the return value in the caller and do your
411+ extra logic there.
412412
413413 You can use :py:attr:`record_type` to override the type associated with
414414 the default :py:attr:`cursor_factory` for your
@@ -442,17 +442,17 @@ def one(self, sql, parameters=None, record_type=None, zero=None, \
442442 42
443443
444444 And if the dereferenced value is :py:class:`None`, we return the value
445- of :py:attr:`zero `:
445+ of :py:attr:`default `:
446446
447- >>> db.one("SELECT sum(baz) FROM foo WHERE bar='nope'", zero =0)
447+ >>> db.one("SELECT sum(baz) FROM foo WHERE bar='nope'", default =0)
448448 0
449449
450450 Dereferencing will use :py:meth:`.values` if it exists on the record,
451451 so it should work for both mappings and sequences.
452452
453453 >>> db.one( "SELECT sum(baz) FROM foo WHERE bar='nope'"
454454 ... , record_type=dict
455- ... , zero =0
455+ ... , default =0
456456 ... )
457457 0
458458
@@ -465,9 +465,9 @@ def one(self, sql, parameters=None, record_type=None, zero=None, \
465465 seq = list (out .values ()) if hasattr (out , 'values' ) else out
466466 out = seq [0 ]
467467
468- # zero
468+ # default
469469 if out is None :
470- out = zero
470+ out = default
471471
472472 return out
473473
0 commit comments