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?

If I'm way off base feel free to let me know, heh, but hopefully this helps! 
:)

Cheers,
Nathan

-- 
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