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

Fix Cockroach Native Query problem #664

Merged
merged 2 commits into from
Dec 16, 2024

Conversation

i-am-tom
Copy link
Contributor

What

Native query tracking fails for CockroachDB because OIDs are 64-bit (despite what the documentation says). However, if we just change the type to i64, then the vanilla Postgres native query setup fails because sqlx requires each type in Rust to correspond to a specific Postgres type, and thus we can't do some sort of dynamic switching.

How

We cast absolutely everything to i64 explicitly in the query. The fact that this works seems to be accidental: because the input type becomes irrelevant, Cockroach determines a different type for oid than Postgres, and both are happy. sqlx bases its types on information from the database, so it's also happy.

I have tested this with tracking a native query in both Cockroach and Postgres, and both seem to be happy.

@i-am-tom i-am-tom self-assigned this Dec 16, 2024
Copy link
Contributor

@danieljharvey danieljharvey left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This makes sense, so long as the types are the same by the time they reach sqlx, everybody is happy.

@i-am-tom i-am-tom force-pushed the i-am-tom/fix-cockroach-native-queries branch from 010596c to 490a1a2 Compare December 16, 2024 13:41
@i-am-tom i-am-tom enabled auto-merge December 16, 2024 13:42
@i-am-tom i-am-tom added this pull request to the merge queue Dec 16, 2024
Merged via the queue into main with commit 0a31c69 Dec 16, 2024
30 checks passed
@i-am-tom i-am-tom deleted the i-am-tom/fix-cockroach-native-queries branch December 16, 2024 14:05
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