On Mon, Feb 22, 2021, at 8:50 PM, Zsolt Ero wrote:
> Hi,
> 
> I'm a bit confused about the scalars() in 1.4+. The "ORM Querying Guide" 
> introduces it in the very first example, but it says:
> "When selecting a list of single-column ORM entities, it is typical to skip 
> the generation of Row objects and instead receive ORM entities directly, 
> which is achieved using the Result.scalars() method."
> https://docs.sqlalchemy.org/en/14/orm/queryguide.html#select-statements
> 
> The confusing part for me is the usage of single-column. The listed query is:
> session.execute(select(User).order_by(User.id))
> or
> SELECT user_account.id, user_account.name, user_account.fullname
> FROM user_account ORDER BY user_account.id
> 
> This is clearly not a single column SQL query.

the "column" it refers towards is that which you'd get in a result row.   I 
don't have a separate term for "elements of a result row" vs. "columns in the 
database".    However I agree that the elements of a result row do not have a 
1-1 correspondence to "columns" so suggestions welcome on what terminology we 
could use.


> 
> 
> I see that the docs say: "single-column ORM entities" but this is quite a 
> puzzling thing to read for me, coming from pre-1.4 background (I've used both 
> ORM and Core for years).
> 
> I always think of the ORM as something which is returning objects possibly 
> with some columns lazy-loaded. But now the whole object is a "ORM column"?
> 
> I'm not suggesting any change to the code, just the documentation is 
> confusing for me.

I think the term "columns" is confusing because it's trying to refer to result 
row elements, not "columns".     We need a PR to fix this up.



> 
> Regards,
> Zsolt
> 
> 
> 
> 

> -- 
> 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/CAKw-smDpHq2K31R%2B1txs-n8kH0_uyC0YfZJf44VKLCsSSFxEwg%40mail.gmail.com
>  
> <https://groups.google.com/d/msgid/sqlalchemy/CAKw-smDpHq2K31R%2B1txs-n8kH0_uyC0YfZJf44VKLCsSSFxEwg%40mail.gmail.com?utm_medium=email&utm_source=footer>.

-- 
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/42d415bf-c9bc-45c1-9b02-301c4bdeca49%40www.fastmail.com.

Reply via email to