Code review comment for lp:~jameinel/maas/1.2-kernel-option-tags

Revision history for this message
Julian Edwards (julian-edwards) wrote :

On Thursday 08 November 2012 05:05:24 you wrote:
> > + tags = tags.order_by('name')[:1]
> > + tag = get_one(tags)
> > + if tag is not None:
> >
> > I trust this is sensible ORM magic.
>
> The order_by is obvious, the [:1] is how you do a LIMIT 1 request, get_one
> is a helper that checks that we get either None or exactly 1 object (there
> is also a get_first helper, though I'm not sure if that gets the LIMIT
> passed down into the DB. It uses islice instead of [:1], which makes me
> think it is iterating the cursor/queryset. Which means the DB might have to
> do all the work just to return 1 item.

You might want to fix get_first() if you think it's not DTRT, and then use it
(so we're consistent across the code base).

Cheers.

« Back to merge proposal