Hi.

As the warning mebtions, the issue is that you are using the string name 
with load only instead of the column from the class.
In this load only from the file:

.load_only('firstname')))

On Thursday, 15 July 2021 at 14:28:29 UTC+2 Mike Bayer wrote:

> i can look later, if i forget after a day or so please post this to github 
> discussions and/or issues where i will notice it better
>
> On Thu, Jul 15, 2021, at 7:44 AM, Lele Gaifax wrote:
>
> Hi,
>
> while upgrading one of my apps to SA 1.4, paying attention toward 2.0
> compatibility, I found one single issue that I was not able to figure out
> whether I'm doing something wrong or missed something in the excellent
> migration guide.
>
> All tests pass, but executing them with SQLALCHEMY_WARN_20 I noticed the
> following message:
>
>   RemovedIn20Warning: Using strings to indicate column or relationship 
> paths
>   in loader options is deprecated and will be removed in SQLAlchemy 2.0...
>
> It was not so simple to isolate the culprit code, but I eventually found 
> the
> cause: here and there my app uses the load_only() option to load a subset 
> of
> the columns of related entities, and that's what upsets the compatibily 
> check.
>
> I'm attaching below a simple script that exhibits the problem (when 
> executed
> with SQLALCHEMY_WARN_20=1).
>
> The documentation[1] shows a very similar usage, so I'm not sure where's 
> the
> problem. Maybe using joinedload(X.y).load_only(a, b), a and b cannot be 
> column
> names under 2.0, but should be Y.a and Y.b instead?
>
> Thanks a lot for any hint,
> ciao, lele.
>
> [1] 
> https://docs.sqlalchemy.org/en/14/orm/query.html#sqlalchemy.orm.Load.load_only
>
> -- 
> 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.
> To view this discussion on the web visit 
> https://groups.google.com/d/msgid/sqlalchemy/87y2a7ls26.fsf%40metapensiero.it
> .
>
>
> -- 
> nickname: Lele Gaifax | Quando vivrò di quello che ho pensato ieri
> real: Emanuele Gaifas | comincerò ad aver paura di chi mi copia.
> le...@metapensiero.it  |                 -- Fortunato Depero, 1929.
>
> -- 
> 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.
> To view this discussion on the web visit 
> https://groups.google.com/d/msgid/sqlalchemy/87y2a7ls26.fsf%40metapensiero.it
> .
>
>
> *Attachments:*
>
>    - test.py
>    
>
>

-- 
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 view this discussion on the web visit 
https://groups.google.com/d/msgid/sqlalchemy/43897be7-0092-42f0-b9b4-338927c44244n%40googlegroups.com.

Reply via email to