Sometimes sqlalchemy produces wrong sql-s. Usually everything works fine, 
but sometimes process enters somehow wrong state and then this process 
starts producing wrong queries over and over again. Exception is as follows:


(psycopg2.ProgrammingError) invalid reference to FROM-clause entry for 
table "my_table"
LINE 2: ... my_table_1.id = sf.my_other_table.parent_id AND 
sf.my_table.volume_id = 123
                                                            ^
HINT: Perhaps you meant to reference the table alias "my_table_1".

It uses real table name instead of an aliased.
It looks like that this is caused by wrong comparator table on aliased 
table:

>>> ParentMyTable.volume_id.comparator.table                                
                                                                            
   
Table('my_table', MetaData(bind=None), ...

ParentDirCurrent is initialized just after process starts with:
ParentMyTable = aliased(MyTable)

In processes that produces correct sqls, it is:

>>> ParentDirCurrent.volume_id.comparator.table
<sqlalchemy.sql.selectable.Alias at 0x7fb991f477b8; %(140434994395064 
dir_current)s>

We use python 3.6, pyinstallered binaries and sqlalchemy==1.1.12.

Usually restarting the process helps, but not always. Could you confirm 
that comparator.table on aliased table should also be aliased table?
Is it already fixed in some newer version?

-- 
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 post to this group, send email to [email protected].
Visit this group at https://groups.google.com/group/sqlalchemy.
For more options, visit https://groups.google.com/d/optout.

Reply via email to