Great, thanks for the follow-up! We've found a workaround using 
inspect(item).expired_attributes.clear() 
after calling through to make_transient_to_detached(item).

Best,
Neena


On Tuesday, September 19, 2017 at 1:38:19 PM UTC-7, Mike Bayer wrote:
>
> On Tue, Sep 19, 2017 at 1:16 PM, Neena Parikh <ne...@benchling.com 
> <javascript:>> wrote: 
> > Hi there, 
> > 
> > After implementing the solutions for raising on column usages brought up 
> at 
> > https://groups.google.com/forum/#!topic/sqlalchemy/Lbyq8Co95mQ, I've 
> come 
> > across an issue where a deferred column is being loaded by default after 
> a 
> > series of function calls. Here's the minimal repro I could find: 
>
> great test, added as 
>
> https://bitbucket.org/zzzeek/sqlalchemy/issues/4084/make_transient_to_pending-expires-deferred.
>  
>
>
> This can be fixed but is targeted at 1.2 (in beta2 right now, beta3 is 
> nearly ready but moving slowly).  Are you able to work around this or 
> do you need a backport to 1.1 ? 
>
> > 
> > 
> > class MyColumn(Column): 
> >     pass 
> > 
> > @compiles(MyColumn) 
> > def compile_column(element, compiler, **kw): 
> >     raise Exception('compile_column') 
> > 
> > class MyTable(): 
> >     id = Column(Integer, primary_key=True) 
> >     deferred_column = deferred(MyColumn(...)) 
> > 
> > 
> > 
> > from sqlalchemy.orm.session import make_transient, 
> > make_transient_to_detached 
> > item = MyTable.query.first()  # doesn't load deferred_column 
> > 
> > make_transient(item) 
> > make_transient_to_detached(item) 
> > db.session.add(item) 
> > db.session.expire_all() 
> > item.id # Ordinarily, loading item.id should not be accessing 
> > deferred_column 
> >> Exception: compile_column 
> > 
> > 
> > 
> > It looks like it's hitting this line: 
> > 
> https://github.com/zzzeek/sqlalchemy/blob/887fb3ebaad20847edc752f5fcf072ace947d56a/lib/sqlalchemy/orm/loading.py#L797,
>  
>
> > which seems to be where the column is getting undeferred — is this 
> behavior 
> > intentional? (There also may be a simpler way to reproduce this 
> behavior.) 
> > If it is intentional, is there anyway to work around this so the column 
> > isn't loaded in? 
> > 
> > (In case it helps, we use make_transient and make_transient_to_detached 
> for 
> > tests to ensure each test starts in the same session state even while 
> using 
> > nested transactions). 
> > 
> > 
> > Thank you! 
> > Neena 
> > 
> > -- 
> > 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+...@googlegroups.com <javascript:>. 
> > To post to this group, send email to sqlal...@googlegroups.com 
> <javascript:>. 
> > Visit this group at https://groups.google.com/group/sqlalchemy. 
> > For more options, visit https://groups.google.com/d/optout. 
>

-- 
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.
For more options, visit https://groups.google.com/d/optout.

Reply via email to