On Tue, Oct 23, 2018 at 9:40 AM Stanisław Skonieczny <stanislaw.skoniec...@gmail.com> wrote: > > 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?
There's no way I can comment on what you are seeing without the mappings, configuation, and usage example which is producing the problem. Additionally when you say it is "sometimes" , is that...certain code paths? or under load? are you using threads? things like that. There's lots of reasons things can go wrong and without a specific reproducer case I can't say much. > > -- > 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 post to this group, send email to sqlalchemy@googlegroups.com. > Visit this group at https://groups.google.com/group/sqlalchemy. > For more options, visit https://groups.google.com/d/optout. -- 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 post to this group, send email to sqlalchemy@googlegroups.com. Visit this group at https://groups.google.com/group/sqlalchemy. For more options, visit https://groups.google.com/d/optout.