On 12/21/2015 08:06 AM, Bernardo wrote:
> Hi,
> 
> I'm trying to use a custom BYTEA-based type on PostgreSQL (9.2) on
> SQLAlchemy 1.0.9., e.g.
> 
> |
> class MySpecialBytea(types.TypeDecorator):
>     impl = BYTEA
> 
>     def process_result_value(self, value, dialect):
>         print "Processing result value in Python"
>         return py_side_process(value) if value is not None else value
>         
>     def column_expression(self, col):
>         return func.sql_side_process(col)
> 
>     # process_bind_param and bind_expression also defined
> 
> |
> 
> However, I have noticed that I can't seem to have both of them apply to
> my entries, as only the column_expression processing seems to apply. If,
> however, I comment that method out, I can readily see the
> process_result_value executing while retrieving the relevant column. 
> I am not sure whether this is intended or a bug,but since the
> counterparts process_bind_paramand bind_expression seem work together in
> my case, I'm inclined to suspect the latter. If it is not, though, is
> there some other way to apply both SQL- and Python-side processing
> simultaneously to my results? I'm currently working around it by
> offloading the Python processing into my application code, but it would
> make more sense and be neater to keep it on the SQLAlchemy layer.

try having the SQL expression itself also be of type MySpecialByteA:

return func.sql_side_process(col, type_=self)  # e.g. self == MySpecialByteA




> 
> -- 
> 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 sqlalchemy+unsubscr...@googlegroups.com
> <mailto:sqlalchemy+unsubscr...@googlegroups.com>.
> To post to this group, send email to sqlalchemy@googlegroups.com
> <mailto:sqlalchemy@googlegroups.com>.
> Visit this group at https://groups.google.com/group/sqlalchemy.
> For more options, visit https://groups.google.com/d/optout.

-- 
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 sqlalchemy+unsubscr...@googlegroups.com.
To post to this group, send email to sqlalchemy@googlegroups.com.
Visit this group at https://groups.google.com/group/sqlalchemy.
For more options, visit https://groups.google.com/d/optout.

Reply via email to