Skip to content
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

Open
wants to merge 12 commits into
base: main
Choose a base branch
from

Conversation

jayy-lmao
Copy link
Contributor

Does your PR solve an issue?

Part 1 of fixing #166

(Breaking apart #3449)

@jayy-lmao
Copy link
Contributor Author

@CommanderStorm and @abonander - first PR breaking this out of the oversized PR #3449.

#[macro_export]
macro_rules! Postgres_query_for_test_prepared_geometric_type {
() => {
"SELECT ({0}::text is not distinct from $1::text)::int4, {0}, $2"
Copy link
Collaborator

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?

Copy link
Contributor Author

@jayy-lmao jayy-lmao Nov 5, 2024

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

Copy link
Collaborator

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.

Copy link
Contributor Author

@jayy-lmao jayy-lmao Nov 6, 2024

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants