I've had a few situations recently when I've been optimizing some
queries that I have been making through the ORM (via Elixir),
and I've wanted to take advantage of deferred columns.  However,
I've found that defining which columns get deferred is often more
appropriate to do at *query* time, not at the time of table/mapper
definition.

I know about deferring groups of columns, and the "defer" option,
but I'd really wish I could do something like this:

     from sqlalchemy.orm import load_only

     results = MyMappedClass.query.options(
         load_only('column_one', 'column_two', 'column_three')
     ).all()

Rather than what I am having to do in many cases where I have 20+
columns on a mapped object:

     desired_columns = ['column_one', 'column_two']
     query = MyMappedClass.query
     for column in MyMappedClass.table.c:
         if column.name not in desired_columns:
             query.options(defer(column))

Does this seem desirable to anyone else, or am I just crazy :)

--
Jonathan LaCour
http://cleverdevil.org

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"sqlalchemy" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/sqlalchemy?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to