-
Notifications
You must be signed in to change notification settings - Fork 1.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat: point #3583
base: main
Are you sure you want to change the base?
feat: point #3583
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why is this necessary? What happens without it?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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)