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

array of custom types serialization fails #1157

Closed
ash-hashtag opened this issue Jul 10, 2024 · 1 comment
Closed

array of custom types serialization fails #1157

ash-hashtag opened this issue Jul 10, 2024 · 1 comment

Comments

@ash-hashtag
Copy link

reproduction

CREATE TYPE Foo AS (
id UUID,
val BOOLEAN
);

CREATE FUNCTION ProcessFoos(foos FOO[])
RETURNS void AS
$$
BEGIN
 -- do something with foos
END;
$$ LANGUAGE plpgsql;


#[derive(postgres_types::ToSql, Debug)]
struct Foo {
   id: Uuid,
   val: Option<bool>
} 

let aSliceOfFoos = vec![ Foo { id: Uuid::max(), val: Some(true) } ];
client.query("SELECT ProcessFoos($1)", &[&aSliceOfFoos]]).await.unwrap();

returns error

Error occurred while creating a new object: error serializing parameter 0: cannot convert between the Rust type `&[Foo]` and the Postgres type `_foo`

I don't know if the _ represents array or maybe it is assuming &[Foo] as a single Foo and trying to serialize it that way?

@ash-hashtag
Copy link
Author

my fault, its just alphabetic casing issue, I expected postgres to not care about it, because its mostly case insensitive.

if anyone runs into same mistake

#940 (comment)

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

No branches or pull requests

1 participant