Code review comment for ~pappacena/launchpad:refactoring-gitrepo-getRefByPath

Revision history for this message
Colin Watson (cjwatson) wrote :

Given that we only want the results for the first matching path, it would be possible to be more precise by doing a query that compiles down to something along the lines of this (for id == 10, path == 'master'):

  SELECT GitRef.*
  FROM GitRef, (VALUES (0, 'master'), (1, 'refs/heads/master')) AS lookup (index, path)
  WHERE GitRef.repository = 10 AND GitRef.path = lookup.path
  ORDER BY lookup.index
  LIMIT 1;

But given that there are always either one or two elements in path, it seems unlikely to be worth very much bother to fine-tune! So feel free to go ahead with your version if you want. I mention it mainly because this sort of approach can be handy in larger cases.

review: Approve

« Back to merge proposal