Re: [sqlalchemy] Migration issues - Column value None on select with joins

2023-05-12 Thread Mike Bayer
in the below mentioned issue I've created a patch at https://gerrit.sqlalchemy.org/c/sqlalchemy/sqlalchemy/+/4615 that removes a thread-sensitive approach to generating an internal structure, which is where I suspect this might be happening (if anywhere), and then it also adds a guard against t

Re: [sqlalchemy] Migration issues - Column value None on select with joins

2023-05-12 Thread Mike Bayer
I've opened https://github.com/sqlalchemy/sqlalchemy/issues/9777 for this. I have another theory where something might be going wrong earler in the chain. This change would be "simpler" in that it removes something that's complicated, prone to race conditions hence seems a good possibility o

Re: [sqlalchemy] Migration issues - Column value None on select with joins

2023-05-12 Thread Shane Holcombe
There seems to be a few moving parts to this so it's been hard to track down, I can give that fix a try in a few hours when I'm home. I was worried something like that might lose some columns but I'll try and see what happens. Thanks On Saturday, May 13, 2023 at 12:59:33 PM UTC+10 Mike Bayer wro

Re: [sqlalchemy] Migration issues - Column value None on select with joins

2023-05-12 Thread Mike Bayer
well, not sure yet how a None is coming in there that is sporadic, or even at all, but if that's what's happening then we would think this patch would fix the problem, the Q is does the query still produce the correct results: diff --git a/lib/sqlalchemy/orm/strategies.py b/lib/sqlalchemy/orm/st

Re: [sqlalchemy] Migration issues - Column value None on select with joins

2023-05-12 Thread Mike Bayer
OK, maybe you are onto something with the theory re: JoinedLoader._generate_row_adapter(). will look at that On Fri, May 12, 2023, at 6:16 PM, Shane Holcombe wrote: > Thanks for linking that github issue, completely missed that one. > > Here's the complete stack trace, sorry for not including th

Re: [sqlalchemy] Migration issues - Column value None on select with joins

2023-05-12 Thread Shane Holcombe
Thanks for linking that github issue, completely missed that one. Here's the complete stack trace, sorry for not including that at the start Traceback (most recent call last): File "/Users/sfh/env/vita/lib/python3.9/site-packages/werkzeug/serving.py", line 333, in run_wsgi execute(self.se

Re: [sqlalchemy] Inconsistent SQL Generation in 2.0

2023-05-12 Thread S Mahabl
https://stackoverflow.com/questions/48811239/how-to-set-alias-in-the-sqlalchemy-for-the-table Another idea is to create a view in another schema pointing to the same table ... On Fri, May 12, 2023 at 3:48 PM Benjamin Taub wrote: > Thanks for the suggestion. > I thought about using an alias but

Re: [sqlalchemy] Inconsistent SQL Generation in 2.0

2023-05-12 Thread Mike Bayer
On Fri, May 12, 2023, at 4:30 PM, Benjamin Taub wrote: > I have code that worked under SQLAlchemy 1.4 but recently upgraded to 2. I am > using the add_columns() method to add columns to an existing SQL statement. > The resultant queries sometimes, but not always, crash. I believe the issue > h

Re: [sqlalchemy] Inconsistent SQL Generation in 2.0

2023-05-12 Thread Benjamin Taub
Thanks for the suggestion. I thought about using an alias but came up with two problems: 1) The FROM clause is auto-generated from SELECT clause, so I'm not sure where I would add this alias 2) All the aliases in the SELECT clause are also double-quoted. I believe a single backquote would be mor

Re: [sqlalchemy] Inconsistent SQL Generation in 2.0

2023-05-12 Thread S Mahabl
Is there alias you can give for *283ac7717fe770c5ed6d425c0c739cba".t_59a33cbea3617986d810e9fbae60ba19 XYZ* *?* On Fri, May 12, 2023, 3:30 PM Benjamin Taub wrote: > I have code that worked under SQLAlchemy 1.4 but recently upgraded to 2. I > am using the add_columns() method to add columns to a

[sqlalchemy] Inconsistent SQL Generation in 2.0

2023-05-12 Thread Benjamin Taub
I have code that worked under SQLAlchemy 1.4 but recently upgraded to 2. I am using the add_columns() method to add columns to an existing SQL statement. The resultant queries sometimes, but not always, crash. I believe the issue happens when the schema/database name (I'm using MySQL) starts wi

Re: [sqlalchemy] Migration issues - Column value None on select with joins

2023-05-12 Thread Mike Bayer
I really need to see: 1. actual models to the degree they illustrate the default loaders set up on relationships 2. query in use 3. **complete** stack trace, put it on a github gist if it's too long. every line, the error, top to bottom. thanks On Fri, May 12, 2023, at 11:25 AM, Mike Bayer wr

Re: [sqlalchemy] Migration issues - Column value None on select with joins

2023-05-12 Thread Mike Bayer
On Fri, May 12, 2023, at 1:25 AM, Shane Holcombe wrote: > AttributeError: 'NoneType' object has no attribute '_from_objects' > (I've shortened this from the entire traceback) OK what kind of traceback, is it a recursion overflow kind of traceback ? (e.g. many hundreds of repeated series of lin

Re: [sqlalchemy] Migration issues - Column value None on select with joins

2023-05-12 Thread Mike Bayer
this has also been reported at https://github.com/sqlalchemy/sqlalchemy/discussions/9666 On Fri, May 12, 2023, at 1:25 AM, Shane Holcombe wrote: > > 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 wher