Skip to content

Instantly share code, notes, and snippets.

@tell-k
Created September 14, 2012 00:04
Show Gist options
  • Save tell-k/3718799 to your computer and use it in GitHub Desktop.
Save tell-k/3718799 to your computer and use it in GitHub Desktop.
# 異なる方法で同じレコードを取り出してみる
entry1 = Entry.query.filter_by(id=1).first()
entry1_another = Entry.query.filter_by(text="entrytext1").first()
# IdentityMapにより同じオブジェクトが返ってくる
if entry1 == entry1_another:
print "same object"
print "entry1 => %s" % (entry1)
print "entry1_another => %s" % (entry1_another)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment