Hi all, Thanks for the replies! Sorry, perhaps I wasn't clear, this is just a minimal example. We are actually storing serialized objects in a column, which can be e.g. dicts or lists of (dehydrated) SQLAlchemy objects, numpy arrays, etc. It's much faster to store (both read and write) a complex structure serialized into a single column than to split it across many tables. Generally this works fine for us, but I just discovered this unusual case, and couldn't see how to solve it.
Changing how we serialize objects is not realistically going to happen, so we are going to continue using TypeDecorators unless there is a better option that enables us to continue doing what we are currently doing. If there were pre-load hooks as well as post-load, then we could set a global variable to object_session(parent_object) for the duration of the load. Alternatively, if the state or context was passed to the TypeDecorator then we could use it to get the session. But right now it appears that there is no hook that does what we want to do. Please would you accept my request to implement something like this? Thanks, Chris. On Tuesday, 28 May 2019 23:42:59 UTC+1, Jonathan Vanasco wrote: > > > > On Tuesday, May 28, 2019 at 4:35:32 PM UTC-4, Mike Bayer wrote: >> >> >> additionally, running SQL inside of a TypeDecorator is not the intended >> usage, as well as using ORM features inside of a TypeDecorator is also not >> the intended usage. >> > > > thanks, mike. I was 99.99% sure that was the case, but didn't want to risk > bring wrong. > -- SQLAlchemy - The Python SQL Toolkit and Object Relational Mapper http://www.sqlalchemy.org/ To post example code, please provide an MCVE: Minimal, Complete, and Verifiable Example. See http://stackoverflow.com/help/mcve for a full description. --- 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. To view this discussion on the web visit https://groups.google.com/d/msgid/sqlalchemy/7850da06-e4a1-4864-8b92-26a817041c6f%40googlegroups.com. For more options, visit https://groups.google.com/d/optout.