Skip to content

Instantly share code, notes, and snippets.

@tell-k
Created September 14, 2012 11:20
Show Gist options
  • Save tell-k/3721382 to your computer and use it in GitHub Desktop.
Save tell-k/3721382 to your computer and use it in GitHub Desktop.
# relationship('Comment', lazy="joined")
# ------------------------------------------
# * 取得タイミング
# * 親と子をJoinしたSQLを発行
# * ちなみに joinedload = eagarload は SQLAlchemyでは異音同義語(シノニム)
#
# entry = Entry.query.filter_by(id=1).first() <- タイミングここ
# entry.comments
#
# * 発行SQL
# SELECT
# anon_1.*, comments_1.*
# FROM
# (SELECT * FROM entries WHERE entries.id = 1 LIMIT 1) AS anon_1
# LEFT OUTER JOIN comments AS comments_1
# ON anon_1.entries_id = comments_1.entry_id
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment