powa-team / powa-web

PoWA user interface
http://powa.readthedocs.io/
73 stars 31 forks source link

Wrong where clause lead to wrong generated SQL #102

Closed anayrat closed 4 years ago

anayrat commented 4 years ago

Hello,

In several part we have such where clause:

.where(c.calls is not None)

Which was translated in SQL with WHERE true.

It seems the fix is replace it by:

.where(c.calls != '0')

Which is translated in

WHERE anon_1.calls != '0'
anayrat commented 4 years ago

More precisely, it is not always the case.

I greped each location where we use .where(c.calls:

And a variant c.calls != None in :

I don't know why, but in server.py and database.py c.calls is not None is translated to true. But in query.py we have c.calls != None which is translated to anon_1.calls IS NOT NULL

I am pretty sure we must change to c.calls != '0' in server.py and database.py. For query.py I must spend more time on it.

rjuju commented 4 years ago

Good catch!

anayrat commented 4 years ago

After investigation c.calls != None in query.py must be changed to c.calls != '0'.