Closed abhay closed 4 years ago
Showing that ordering matters for the PR history
etl=> select block, coalesce(block, 441087) from gateway_status where address = '11VVxHxDN8Soxo7ATugLJBfKDXdQdAhGCeRkbXBKGM4evPgvTp5';
block | coalesce
--------+----------
434982 | 434982
(1 row)
etl=> select block, coalesce(441087, block) from gateway_status where address = '11VVxHxDN8Soxo7ATugLJBfKDXdQdAhGCeRkbXBKGM4evPgvTp5';
block | coalesce
--------+----------
434982 | 441087
(1 row)
etl=> select block, coalesce(NULL, block) from gateway_status where address = '11VVxHxDN8Soxo7ATugLJBfKDXdQdAhGCeRkbXBKGM4evPgvTp5';
block | coalesce
--------+----------
434982 | 434982
(1 row)
etl=> select block, coalesce(441087, NULL) from gateway_status where address = '11VVxHxDN8Soxo7ATugLJBfKDXdQdAhGCeRkbXBKGM4evPgvTp5';
block | coalesce
--------+----------
434982 | 441087
(1 row)
etl=> select block, coalesce(NULL, NULL) from gateway_status where address = '11VVxHxDN8Soxo7ATugLJBfKDXdQdAhGCeRkbXBKGM4evPgvTp5';
block | coalesce
--------+----------
434982 |
(1 row)
The COALESCE function returns the first non-NULL argument so we were losing the new value for the old one if it wasn't NULL which is the opposite of what we wanted.
CC: @madninja