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

postgres-types: Can't insert oidvector #1025

Closed
mstrydom opened this issue Apr 27, 2023 · 4 comments · Fixed by #1027
Closed

postgres-types: Can't insert oidvector #1025

mstrydom opened this issue Apr 27, 2023 · 4 comments · Fixed by #1027

Comments

@mstrydom
Copy link

postgres-types does not seem to have built in support for oidvector. I tried to do this by inserting vec![1_u32, 2_u32] as a Vec<Oid>, but doing so results in:

invalid oidvector data

Which seems to come from this line in the Postgres codebase. It looks to me like Postgres assumes a lower_bound of 0, but ToSql of Vec is always setting it as 1.

Is there another way to send in oidvector as a bound parameter?

@sfackler
Copy link
Owner

sfackler commented Apr 27, 2023

https://docs.rs/postgres_array/latest/postgres_array/ provides more control over array types.

@sfackler
Copy link
Owner

Though we could (and probably should) update that ToSql impl to use a lower_bound of 0 when the target type is oidvector.

@mstrydom
Copy link
Author

https://docs.rs/postgres_array/latest/postgres_array/ provides more control over array types.

I will take a look at that and see if it solves the problem. Thanks!

@mstrydom
Copy link
Author

mstrydom commented May 1, 2023

I can confirm that postgres_array does solve my problem, thanks! I did have to muck around with some extra formatting/to_string conversions to get it to format the same in Rust as in Postgres, so I still think having an explicit oidvector type might be nice. But feel free to resolve this issue if you do not agree that more work is warranted here.

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 a pull request may close this issue.

2 participants