Hi there,
I've been working on migrating our codebase from SQLAlchemy 1.4 to 2.0 and
have encountered an issue I can't seem to get around.
The error itself is
File
"/Users/sfh/env/vita/lib/python3.9/site-packages/sqlalchemy/orm/context.py",
line 1101, in create_for_statement
SelectState.__init__(self, self.statement, compiler, **kw)
File
"/Users/sfh/env/vita/lib/python3.9/site-packages/sqlalchemy/sql/selectable.py",
line 4501, in __init__
self.froms = self._get_froms(statement)
File
"/Users/sfh/env/vita/lib/python3.9/site-packages/sqlalchemy/sql/selectable.py",
line 4599, in _get_froms
[
File
"/Users/sfh/env/vita/lib/python3.9/site-packages/sqlalchemy/sql/selectable.py",
line 4600, in <listcomp>
element._from_objects
AttributeError: 'NoneType' object has no attribute '_from_objects'
(I've shortened this from the entire traceback)
>From the digging around that I've done, it seems to be the ColumnLoader
strategy setup_query method sometimes has a value for 'c' of None where an
adapter is present but check_for_adapt is False. This is from the c =
adapter.columns[c] line.
This happens only when called from the JoinedLoader class, it seems
the _generate_row_adapter method returns a clauses object with a columns
dict that has all the keys from the underlying table, but some of the
values are None.
All of this behaviour is fairly hard to get to happen however it seems to
occur after the warning "Loader depth for query is excessively deep;
caching will be disabled for additional loaders. Consider using the
recursion_depth feature for deeply nested recursive eager loaders." occurs.
This warning comes from a different part of the system where the base level
object, 'User', is very deeply nested, and on some later request to a
different part of the system, fetching a different 'User' relationship at a
less deep level triggers the above error.
In our use case we have some fairly deeply nested relationships, 6 or so
levels deep, however we never used selectinload or immediateload to my
knowledge so there is no way to change the recursion depth.
Any help on this would be fantastic,
Thanks,
Shane
--
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 [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/sqlalchemy/f6ee8641-0dc8-4eec-a79e-941ac3d814b9n%40googlegroups.com.