well .key on any ColumnElement is supposed to be a string name that Query and 
others will call upon to assign it a label in the result set.   removing .key, 
which is unneeded, allows it to work (note expr.clauses):

class PGCompositeElement(expression.FunctionElement):
    def __init__(self, base, field, type_):
        self.name = field
        self.type = to_instance(type_)

        super(PGCompositeElement, self).__init__(base)


@compiles(PGCompositeElement)
def _compile_pgelem(expr, compiler, **kw):
    return '(%s).%s' % (compiler.process(expr.clauses, **kw), expr.name)



On Mar 25, 2013, at 3:24 PM, Tobias Bieniek <[email protected]> 
wrote:

> Sorry, just noticed that I replied directly, instead of to the list. Here are 
> the contents for everyone:
> 
> Thanks for you help. Using the FunctionElement worked quite well, but
> I had to tweak the constructor and assign the base parameter to
> self.key to make it work properly (failing stack trace at
> https://gist.github.com/Turbo87/b5f49ffeedb3fa288b4f).
> 
> Now I've tried the same approach using the declarative method
> (https://gist.github.com/Turbo87/e7fb19b8e532d3e3b6f3) but I get the
> next error: "TypeError: Boolean value of this clause is not defined"
> (stack trace for that is at
> https://gist.github.com/Turbo87/ab5f0ef5159dc85dd0b3 and what I got
> out of the debugger is at
> https://gist.github.com/Turbo87/bef75287f67c0f1f948a)
> 
> I hope I'm not stealing too much of your time. Thanks again for the
> great help already!
> 
> -- 
> You received this message because you are subscribed to the Google Groups 
> "sqlalchemy" group.
> To unsubscribe from this group and stop receiving emails from it, send an 
> email to [email protected].
> To post to this group, send email to [email protected].
> Visit this group at http://groups.google.com/group/sqlalchemy?hl=en.
> For more options, visit https://groups.google.com/groups/opt_out.
>  
>  

-- 
You received this message because you are subscribed to the Google Groups 
"sqlalchemy" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/sqlalchemy?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.


Reply via email to