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

Revision history for this message
John A Meinel (jameinel) 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.

« Back to merge proposal