On May 25, 2011, at 10:52 PM, Nathan Wright wrote: > Hi all, > > I've run into an issue when mapping a deferred column_property that uses a > custom SQL construct. I get a KeyError: 'default' because there is no compile > function for the default dialect, but it seems to me that the default dialect > should never be used. > > Here's an extended stack trace of what's going on, the important bit is lines > 78-90: > http://pastebin.com/0kVf9q9q > > And here's the a simplified test case: > > class utcnow(expression.FunctionElement): > type = DateTime() > > @compiles(utcnow, 'postgresql') > def pg_utcnow(element, compiler, **kw): > return "TIMEZONE('utc', CURRENT_TIMESTAMP)" > > mapper(AnyClass, any_table, properties={ > 'timestamp': column_property(select([utcnow()]), deferred=True) > }) > > Session.query(AnyClass).all() > > > For now I'm just adding a dummy @compiles(utcnow) function for the default > dialect, but I think this could be avoided entirely by changing the > NoSuchColumnError message to not cast key (ie, the select) to a string. > Perhaps the repr could be used instead?
the __repr__() produces IMHO a less descriptive string in the case of a "no such column" type of situation: sqlalchemy.exc.NoSuchColumnError: "Could not locate column in row for column '<sqlalchemy.sql.expression._Label object at 0x1124490>'" Being able to see the expression is most meaningful. http://www.sqlalchemy.org/trac/ticket/2178 provides a patch, which is an improvement on the situation. -- 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.