Skip to content

add a one_or_zero method #19

@chadwhitacre

Description

@chadwhitacre

Often you are fine with zero or one result but more than one would indicate a bug. Right now you can do:

try:
    rec = db.one(QUERY)
except TooFew:
    rec = None

if rec is None:
    pass
else:
    pass

But it might be nicer to be able to do:

rec = db.one_or_zero(QUERY)
if rec is None:
    pass
else:
    pass

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions