Re: [sqlalchemy] Caching with selectedinload causing AttributeError: 'PathToken' object has no attribute 'serialize'

119 views
Skip to first unread message

Mike Bayer

unread,
Mar 19, 2022, 8:45:12 PM3/19/22
to noreply-spamdigest via sqlalchemy
that is an immensely complicated query and I couldn't tell you what's going on with that being the only context provided, unfortunately.

On Fri, Mar 18, 2022, at 10:16 PM, Michael Bukachi wrote:
Hello,

So I've got a very weird when trying to set up caching using dogpile based on the examples provided. I'm using the latest version of SQLAlchemy 1.4. For some strange reason using selectinload and attempting to cache the frozen result is causing  <AttributeError: 'PathToken' object has no attribute 'serialize':
Here are the load options I'm using:

load_options: Optional[List] = [
joinedload(CatalogProduct.partner).load_only(
"name", "partner_type", "status"
),
joinedload(CatalogProduct.product).options(
selectinload(Product.attributes),
selectinload(Product.values),
joinedload(Product.subcategory).joinedload(Subcategory.category),
joinedload(Product.template).selectinload(ProductTemplate.attributes),
),
selectinload(CatalogProduct.uoms)
.joinedload(CatalogProductUoM.uom)
.load_only("name"),
joinedload(CatalogProduct.default_uom)
.joinedload(CatalogProductUoM.uom)
.load_only("name"),
joinedload(CatalogProduct.restock_uom)
.joinedload(CatalogProductUoM.uom)
.load_only("name"),
selectinload(CatalogProduct.areas)
.joinedload(CatalogProductArea.marketplace_area)
.joinedload(CatalogMarketplaceArea.area)
.load_only("name"),
selectinload(CatalogProduct.excluded_areas)
.joinedload(CatalogMarketplaceArea.area)
.load_only("name"),
selectinload(CatalogProduct.allowed_areas).load_only(
"partner_id", "area_id"
),
selectinload(CatalogProduct.images),
joinedload(CatalogProduct.default_image),
joinedload(CatalogProduct.supplier).load_only(
"name", "partner_type", "status"
),
raiseload("*"),
]

if I replace all the root selectinloads with joinedloads I don't get the error. Is there something to do with selectinloads and caching that I'm missing? Perhaps, ordering?


--
SQLAlchemy -
The Python SQL Toolkit and Object Relational Mapper
 
 
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.

Reply all
Reply to author
Forward
0 new messages