Skip to content

Instantly share code, notes, and snippets.

@nahi
Created September 9, 2009 12:11
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save nahi/183674 to your computer and use it in GitHub Desktop.
Save nahi/183674 to your computer and use it in GitHub Desktop.
# 怪しいコード
pinned = Pin.find(
:all,
:conditions => [ 'user_id = ?', auth.id ],
:joins => 'LEFT OUTER JOIN last_modifieds ON pins.eid = last_modifieds.eid',
:order => 'last_modifieds.date desc',
:offset => start,
:limit => num
)
# 発行されているクエリ
SELECT "pins".* FROM "pins" LEFT OUTER JOIN last_modifieds ON pins.eid = last_modifieds.eid WHERE (user_id = XXX) ORDER BY last_modifieds.date desc LIMIT 10 OFFSET 0
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment