On May 19, 2009, at 10:39 AM, Tiago Becker wrote:
> Hi. > > Im still trying to use the select object from sqlalchemy, but i > found a strange (bug or not) behavior: > > sql = select(columns=[self.fields], from_obj=self.tables, > whereclause=self.where, bind=self.req.cfg.engine, order_by= ' 1 ') > > 1) without order by, i get an error: AttributeError: 'NoneType' > object has no attribute 'proxies'. is this intended? this indicates a None is being sent as a column somewhere. > 2) the select fails when theres a CASE instruction, like this: > > case field1 > when 34 then field2 > when 94 then field3 > when 48 then field4 > end another_field > > It fails because sqlalchemy does a subquery, but instead of using * > (in the outer query, to bring all the fields) it just paste the same > fields from the original query, failing to get all the fields in the > case expression.... I dont see the SQLAlchemy expression you're dealing with here. the symptom you describe is when placing a FROM object in the columns clause of a SELECT, the object is also added to the FROM clause automatically, unless additional steps are taken to prevent this. A CASE statement is not is not a FROM object, its a column object, so this should not occur. If you are placing a SELECT in the columns clause of another SELECT, call as_scalar() on it. --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
