Created
April 8, 2014 17:17
-
-
Save RonnyPfannschmidt/10158241 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# current method | |
obj = session.query(Foo).get(id) # select * from foo where id=? | |
obj.bar = session.query(Bar).get(bar_id) # select * from bar where id=? | |
# what i want: | |
obj = session.query(Foo).get(id) # select * from foo where id=? | |
obj.bar = session.hollow(Bar, bar_id) # invented name, no query should happen until i use attributes of obj.bar | |
# what i want to avoid | |
obj = session.query(Foo).get(id) # select * from foo where id=? | |
obj.bar_id = bar_id | |
# why do i want to avoid? | |
""" | |
im dealing with a old where id fields are very commonly missued in `interesting` ways, | |
to remove that issue and the possibility to reintoroduce them | |
instead of id columns i always want to be able to work in terms of relationships and instances | |
btw, i'd love if foo.relationship would return a `hollow` instance as well, since for assignments i don't need a filled instance and db queries - just passing a id in disguise around after all | |
""" | |
zzzeek
commented
Apr 9, 2014
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment