Indeed, this just seems like a common need.
Mike, is it common enough to warrant going on the session by default?
cheers,
Chris
On 17/06/2013 18:57, Petr Viktorin wrote:
Simply handling NoResultFound should work just fine...
def zero_or_one(query):
try:
return query.one()
From the docs:
one()
Return exactly one result or raise an exception.
Raises sqlalchemy.orm.exc.NoResultFound if the query selects no rows.
Raises sqlalchemy.orm.exc.MultipleResultsFound if multiple object
identities are returned, or if multiple rows are returned for a query
that does not
Hi All,
I seems to commonly need to do a query which should return zero or one
mapped objects.
.one() isn't what I want as no returned object is ok.
.first() isn't what I want as if my query would return more than one
object, I have the query wrong and so want an exception.
Is there
On Jun 17, 2013, at 08:58 , Chris Withers ch...@simplistix.co.uk wrote:
Hi All,
I seems to commonly need to do a query which should return zero or one mapped
objects.
.one() isn't what I want as no returned object is ok.
.first() isn't what I want as if my query would return more
On Jun 17, 2013, at 5:33 AM, Wichert Akkerman wich...@wiggy.net wrote:
On Jun 17, 2013, at 08:58 , Chris Withers ch...@simplistix.co.uk wrote:
Hi All,
I seems to commonly need to do a query which should return zero or one
mapped objects.
.one() isn't what I want as no returned
Am 17.06.2013, 08:58 Uhr, schrieb Chris Withers ch...@simplistix.co.uk:
Hi All,
I seems to commonly need to do a query which should return zero or one
mapped objects.
.one() isn't what I want as no returned object is ok.
.first() isn't what I want as if my query would return more than
Simply handling NoResultFound should work just fine...
def zero_or_one(query):
try:
return query.one()
except NoResultFound:
return None
On Mon, Jun 17, 2013 at 6:36 PM, Michael Bayer mike...@zzzcomputing.com wrote:
On Jun 17, 2013, at 5:33 AM, Wichert Akkerman