Conversation
|
@CommanderStorm and @abonander - first PR breaking this out of the oversized PR #3449. |
sqlx-test/src/lib.rs
Outdated
| #[macro_export] | ||
| macro_rules! Postgres_query_for_test_prepared_geometric_type { | ||
| () => { | ||
| "SELECT ({0}::text is not distinct from $1::text)::int4, {0}, $2" |
There was a problem hiding this comment.
Why is this necessary? What happens without it?
There was a problem hiding this comment.
We get the error could not identify an equality operator for type point without it
We can't use the SELECT ({0} is not distinct from $1)::int4, {0}, $2 from https://github.com/jayy-lmao/sqlx/blob/feat/geometry-postgres-point/sqlx-test/src/lib.rs#L230 as the comparison
https://github.com/launchbadge/sqlx/actions/runs/11679795147/job/32521594696
There was a problem hiding this comment.
I see. = compares area for the two-dimensional types, and there's a different operator for equality, ~=.
https://www.postgresql.org/docs/current/functions-geometry.html
We should use that rather than converting from text because there could be differences in rounding between Postgres and Rust that alter the text output of the types.
There was a problem hiding this comment.
Took a bit of a fiddle, and needed to split between array/non-array variants.
This is what worked in the end, text avoided: https://github.com/launchbadge/sqlx/pull/3583/files#diff-31a2fb7770cf7cd19a7baadb82c0ccfa1721d92c1eeb4d3f7f9a675de54f20b0R247-R251
Does your PR solve an issue?
Part 1 of fixing #166
(Breaking apart #3449)