I upgrade to 0.5.5 from 0.5.2 the other day and it broke a working
query.  I was simply querying the maximum year in my table, by
extracting from the date column:

query = session.query(extract('year', Order.date).label
('year')).distinct().subquery()     <-- Exception raised here

min = int(func.min(query.c.year).scalar())
max = int(func.max(query.c.year).scalar())

This worked exactly as I wanted when I ran it 0.5.2, however it broke
when I upgraded to 0.5.5.  I tried a couple of other releases, and it
works in 0.5.3 but fails in 0.5.4 and above.  Below is the stack trace
and exception I get.  BTW, I'm using postgres.

db.queries.minMaxYr()
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "db/queries.py", line 96, in minMaxYr
    query = session.query(extract('year', Order.date).label
('year')).distinct().subquery()
  File "/Library/Frameworks/Python.framework/Versions/2.6/lib/
python2.6/site-packages/SQLAlchemy-0.5.5-py2.6.egg/sqlalchemy/orm/
scoping.py", line 123, in do
    return getattr(self.registry(), name)(*args, **kwargs)
  File "/Library/Frameworks/Python.framework/Versions/2.6/lib/
python2.6/site-packages/SQLAlchemy-0.5.5-py2.6.egg/sqlalchemy/orm/
session.py", line 895, in query
    return self._query_cls(entities, self, **kwargs)
  File "/Library/Frameworks/Python.framework/Versions/2.6/lib/
python2.6/site-packages/SQLAlchemy-0.5.5-py2.6.egg/sqlalchemy/orm/
query.py", line 91, in __init__
    self._set_entities(entities)
  File "/Library/Frameworks/Python.framework/Versions/2.6/lib/
python2.6/site-packages/SQLAlchemy-0.5.5-py2.6.egg/sqlalchemy/orm/
query.py", line 98, in _set_entities
    entity_wrapper(self, ent)
  File "/Library/Frameworks/Python.framework/Versions/2.6/lib/
python2.6/site-packages/SQLAlchemy-0.5.5-py2.6.egg/sqlalchemy/orm/
query.py", line 2047, in __init__
    for elem in visitors.iterate(column, {})
  File "/Library/Frameworks/Python.framework/Versions/2.6/lib/
python2.6/site-packages/SQLAlchemy-0.5.5-py2.6.egg/sqlalchemy/
util.py", line 762, in __init__
    self.update(d)
  File "/Library/Frameworks/Python.framework/Versions/2.6/lib/
python2.6/site-packages/SQLAlchemy-0.5.5-py2.6.egg/sqlalchemy/
util.py", line 800, in update
    for i in iterable:
  File "/Library/Frameworks/Python.framework/Versions/2.6/lib/
python2.6/site-packages/SQLAlchemy-0.5.5-py2.6.egg/sqlalchemy/orm/
query.py", line 2048, in <genexpr>
    if 'parententity' in elem._annotations
AttributeError: 'str' object has no attribute '_annotations'

Any help would be greatly appreciated.

Thanks,

Mike

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

Reply via email to