3 ms·
Don't most ORM allow that? i.e. rails' ActiveRecord allows you to select columns easily in most cases: User.where(..) # all fields User.where(..).sele
by riffraff 13y ago
Don't most ORM allow that?
i.e. rails' ActiveRecord allows you to select columns easily in most cases:
User.where(..) # all fields
User.where(..).select(:name, :id) # only two of them
joe.boards.select(:title) # only one in join
joe.boards.pluck(:title) # only column value instead of full objects with one attribute set
Though I recall it's involved for #belongs_to relations.
You should also be able to setup the select as a default per-class, other than per query.
I suspect, I likely didn't understand your question, could you expand it?
- andrewflnr 13y agoIt's possible I'm just ignorant of the capabilities of most ORMs. My only real experience is with the Django ORM. AFAIK, if you select an object, it wants to make sure all the members of the object are populated. My apologies if it was a dumb question. :)
- byroot 13y agoBy default yes, but like most ORMs you can ask to populate only some members: https://docs.djangoproject.com/en/dev/ref/models/querysets/#only https://docs.djangoproject.com/en/dev/ref/models/querysets/#...
- meric 13y agoDjango has it too. https://docs.djangoproject.com/en/dev/ref/models/querysets/#defer https://docs.djangoproject.com/en/dev/ref/models/querysets/#...