Hey,

I'm having a trouble with `joinedload`ing relationships in my models, since 
I updated SQLAlchemy from 1.1.2 to 1.1.6.
Sometimes, (and when I say sometimes, i mean 1 out of 50 times or something 
like that), when spinning up a server of my python app which uses 
SQLAlchemy, I will face this error:

AttributeError: 'NoneType' object has no attribute '_annotations'


I did some digging in the code, and it turns out the `memoized_setups` for 
this relationship has empty values in the columns.

Lets say I have two models:


> class A(Model):
>   id = Column(Integer, primary_key=True)
>   b_id = Column(Integer, ForeignKey('b.id'))
>   b = relationship(B)
>
 

class B(Model):
>   id = Column(Integer, primary_key=True)
>   foo = Column(String)
>
>
When I face the error, and dig up in the code, I find:

In sqlalchemy/orm/strategies.py in create_row_processor:

our_path = PropRegistry((<Mapper at 0x7f4fe2ae9048; A>, 
> <RelationshipProperty at 0x7f4fe2ae1c48; b>))


which calls _instance_processor in sqlalchemy/orm/loading.py:  (with 
`context=context` and `path=our_path[mapper]`)

quick_populators = path.get(
> context.attributes, "memoized_setups", _none_set)


with leads to: quick_populators =

{
> <ColumnProperty at 0x7f3fe2d01710; id>: Column('id', BIGINT(), 
> table=<%(137911348719792 b)s>, primary_key=True, nullable=False), 
> <ColumnProperty 
> at 0x7f3fe2d01808; foo>: None, }


It's then when trying to get quick_populator[column_object] (which is None) 
that I get the error above.

It looks like the context which is passed to `_instance_processor` had bad 
memoized data. I have absolutely no clue about what's happening, nor about 
a reliable way to reproduce the issue; as said, it happens (randomly?) once 
in a while when spinning up a server.

Has it ever happened to you? Do you have a solution for that? Is there more 
data you need to evaluate the bug?
NB: everytime this happens (which is not often), I just have to restart the 
server and it works. Guess it is just bad data memoized at setup time.

Thanks for reading,
Martin








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