On Dec 27, 2009, at 12:01 PM, Adam Dziendziel wrote:

> Hi,
> 
> I am trying to implement versioning of a structure of interconnected
> objects so that I can see how the content looked at some point of
> time.
> 
> Probably I would need to use a temporal database with effective_from/
> effective_to timestamps telling the time period when the information
> held in the record was true: http://martinfowler.com/ap2/timeNarrative.html
> 
> If I had a flat object structure, I would simply pass a filter on the
> query:
> 
> session.query(Object).filter(Object.effective_from >= time & time <
> Object.effective_to)
> 
> However, in my schema, the Object has related entities which is also
> temporal data. The mapped relations ideally should have the 'time'
> parameter embedded in the ON part of JOIN clause.
> 
> I know that I can declare all relations as lazy='dynamic' and always
> pass 'time'. But I would then lost the possibility to eagerly load
> data. It would be inefficient to retrieve a record set and for each
> record issue another queries to get values of temporal properties
> ( http://martinfowler.com/eaaDev/TemporalProperty.html )
> 
> What I am looking for is a parameter, which value is specified once
> during a query, that could be used in mapper declarations. Attribute
> loaders would then use that parameter automatically. Is this possible
> in SQLAlchemy?

this answer to this required enough creativity and testing that I made it into 
a usage recipe.   Please give it a road test at 
http://www.sqlalchemy.org/trac/wiki/UsageRecipes/GlobalFilter and let me know 
if its effective.


--

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