I'm running a query using PostgreSQL 9.6.6 and when querying:
SELECT *
FROM table
WHERE
threshold_value < VALUE
returns all values = VALUE and not < VALUE as it should. In the same way if I query
SELECT *
FROM table
WHERE
threshold_value = VALUE
Shows no values at all when all threshold_value (values) are equal to VALUE (VALUE is 1.4)
My threshold_value
column is of type real
. Should this be happening, or is it a known bug? Is this related to conversion errors between the python implementation of PGAdmin and the DB, or am I missing something?
numeric
(in Postgres) andDecimal
(in Python) if you want accuracy (to a specific or arbitrary hight accuracy). Or use float/real but never test for equality. Only<
and<=
and beware that some values, like1.4
will never be represented exactly as you send them (to Python or Postgres) and make your applications aware. – ypercubeᵀᴹ Mar 27 '18 at 18:45