Q:

Undo `lazyload()` with the relationship default

I have a Query object which was initially configured to lazyload() all relations on a model:
query = session.query(Article).options(lazyload('author'))

Is it possible to revert the relationship loading back to default? E.g. the relationship was configured with lazy='joined', and I want the query to have joinedload() behavior without using joinedload() explicitly. 
I was expecting defaultload() to have this behavior, but in fact it does not: it references the query default instead of the relationship default. So I'm searching for kinda resetload() solution.

The reason for doing this is because I'm creating a JSON-based query syntax, and no relations should be loaded unless the user explicitly names them.
Currently, I'm using lazyload() on all relations that were not explicitly requested, but want to go the other way around:  lazyload() all relations first, and then override it for some of them. 
This would have made the code more straigntforward.

A:

Just to be clear:

By default, all inter-object relationships are lazy loading.

http://docs.sqlalchemy.org/en/latest/orm/loading.html
So we are talking about a case in which a relation has been specifically marked as eager loading, then the queries are configured as lazy loading, then you want to "override the override" as it were.
Chaining calls to options will override earlier calls. I did test this a bit.
q = s.query(User)  # lazy loads 'addresses'
q = s.query(User).options(contains_eager('addresses'))  # eager loads
q = s.query(User).options(contains_eager('addresses'))\
        .options(lazyload('addresses'))  # lazy loads
q = s.query(User).options(contains_eager('addresses'))\
        .options(lazyload('addresses'))\
        .options(contains_eager('addresses'))  # eager loads

However, it sounds like you're talking about just reverting the lazyload option, whereas the above case involves an explicit change to eager loading.
The defaultload docstring says its use case is to be chained to other loader options, so I don't think it's related.
Based on a glance through the source, I don't think this behavior is supported. When you update the loading strategy option, it updates a dictionary with the new loading strategy and I don't think there's still a reference to the old strategy, at least as far as I can tell.
You could keep a reference to the query object before .options(lazyload(...)), or just have an option to generate the query with or without the lazyload on everything.

