Skip to content

Instantly share code, notes, and snippets.

@tell-k
Created September 14, 2012 11:19
Show Gist options
  • Save tell-k/3721376 to your computer and use it in GitHub Desktop.
Save tell-k/3721376 to your computer and use it in GitHub Desktop.
# relationship('Comment', lazy="immediate")
# ------------------------------------------
# * 取得タイミング
# * 親のモデルがロードされたタイミング一緒にSQL発行
# * lazy="select"とはタイミングが違うだけで発行してるSQLは一緒
#
# entry = Entry.query.filter_by(id=1).first() <- タイミングここ
# entry.comments
#
# * 発行SQL
# 1. SELECT * FROM entries WHERE entries.id = 1 LIMIT 1
# 2. SELECT * FROM comments WHERE comments.entry_id =1
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment