cayenne-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Andrus Adamchik <and...@objectstyle.org>
Subject Re: Chainable SelectQuery
Date Sat, 29 Nov 2014 07:38:57 GMT

> On Nov 29, 2014, at 4:09 AM, Aristedes Maniatis <ari@maniatis.org> wrote:
> 
> On 29/11/2014 1:01am, Andrus Adamchik wrote:
>> Just added another flavor of select method - 'selectFirst'. Unlike 'selectOne' intended
for queries that expect at most one row back, 'selectFirst' is a quick way to get the top-of-the-list
object, even if the query matched many objects. I.e. it is equivalent to "limit(1).selectOne(context)".
> 
> * Does selectOne() throw an exception if it gets back more than one row? Is that the
main difference between the functions for a user?

Correct.

> * For performance reasons, should selectOne put LIMIT 2 into the SQL since it will only
discard additional objects anyway?

We may. Though since it throws in such cases, it would only be relevant if there's a programmer
error (query syntax implies > 1 row) or ref integrity problem in DB (no unique constraint
where it is expected), so this has never been a problem in practice.

Andrus
Mime
View raw message