Re: [sqlalchemy] aliased(MyTable).my_column.comparator.table sometimes is instance of Table instead of Alias

2018-10-29 Thread Stanisław Skonieczny
I did as you said. We will see if this helps. BTW. We do not do any live code reloading. We just restart the entire process. On Thursday, 25 October 2018 15:03:18 UTC+2, Mike Bayer wrote: > > is there a reason this AliasedClass has to be global?The object > has a lot of memoizations, e.g.

Re: [sqlalchemy] aliased(MyTable).my_column.comparator.table sometimes is instance of Table instead of Alias

2018-10-25 Thread Mike Bayer
is there a reason this AliasedClass has to be global?The object has a lot of memoizations, e.g. attributes that construct themselves only when first accessed, and it seems likely that some very subtle race is occurring within this process given that your application is also reloading. I

Re: [sqlalchemy] aliased(MyTable).my_column.comparator.table sometimes is instance of Table instead of Alias

2018-10-25 Thread Stanisław Skonieczny
I have seen that when I connected to a process that produced wrong sql-s. I used pyrasite to attach to a live process. I compared sql-alchemy structures inside with a process that produced correct sql's. That is the difference I have found: in the process that produces good sql-s,

Re: [sqlalchemy] aliased(MyTable).my_column.comparator.table sometimes is instance of Table instead of Alias

2018-10-24 Thread Mike Bayer
On Wed, Oct 24, 2018 at 4:12 AM Stanisław Skonieczny wrote: > > It uses threads. It may be correlated with high load, as it usually happens > when process is run during upgrade. Schema of the table is as follows (I have > removed unrelated tables and fields): OK so this is not something you

Re: [sqlalchemy] aliased(MyTable).my_column.comparator.table sometimes is instance of Table instead of Alias

2018-10-24 Thread Stanisław Skonieczny
Query that behaves badly is: session.query(MyTable).join(MyOtherTable, and_( ParentMyOtherTable.id == MyTable.parent_id, ParentMyOtherTable.volume_id == MyTable.volume_id )) On Wednesday, 24 October 2018 10:12:43 UTC+2, Stanisław Skonieczny wrote:

Re: [sqlalchemy] aliased(MyTable).my_column.comparator.table sometimes is instance of Table instead of Alias

2018-10-24 Thread Stanisław Skonieczny
It uses threads. It may be correlated with high load, as it usually happens when process is run during upgrade. Schema of the table is as follows (I have removed unrelated tables and fields): from sqlalchemy import Column, BigInteger, ForeignKey from sqlalchemy.ext.declarative import

Re: [sqlalchemy] aliased(MyTable).my_column.comparator.table sometimes is instance of Table instead of Alias

2018-10-23 Thread Mike Bayer
On Tue, Oct 23, 2018 at 9:40 AM Stanisław Skonieczny 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: > > >

[sqlalchemy] aliased(MyTable).my_column.comparator.table sometimes is instance of Table instead of Alias

2018-10-23 Thread Stanisław Skonieczny
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