CartoDB / observatory-extension

BSD 3-Clause "New" or "Revised" License
6 stars 4 forks source link

Fix tests for PG10 #330

Closed juanignaciosl closed 6 years ago

juanignaciosl commented 6 years ago

Tests are failing in PG10: https://travis-ci.org/CartoDB/observatory-extension/jobs/362144496

juanignaciosl commented 6 years ago

This is caused by the change in the behavior of = operator in 2.4: "3844, Make = operator a strict equality test". Until 2.4, it compared equality of bounding boxes. There were tests abusing from that at checks:

https://github.com/CartoDB/observatory-extension/blob/2183b7fc264e3cbe5a9986480ddeccffdf75f497/src/pg/test/sql/44_observatory_geometries_test.sql#L15-L19

In the future, we should improve the test data so we can use strict equality. Meanwhile, as a fast way to transition to PostgreSQL 10, we could change the check to the old behavior:

SELECT st_envelope(cdb_observatory.OBS_GetBoundary(
  cdb_observatory._TestPoint(),
  'us.census.tiger.census_tract'
)) = st_envelope(st_asewkb(:'cartodb_census_tract_geometry')) As OBS_GetBoundary_cartodb_census_tract;

@pramsey what do you think about this workaround?

cc @ethervoid

pramsey commented 6 years ago

That workaround should be fine. Envelopes always start/end at the same place. One possible issue? Is that the = operator checked the equality of the float4 bounds, not the float8 bounds, so it's possible that you might still have objects that show up as having envelope != envelope even though they previously tested true using =.

juanignaciosl commented 6 years ago

Tests passed, so it should be fine 👍 For future testing we should probably use exact geometries and ST_Equals.