sfackler / rust-postgres

Native PostgreSQL driver for the Rust programming language
Apache License 2.0
3.42k stars 436 forks source link

Struct/Composite Type with Schema Name Question (postgres-types) #1083

Closed danielnehrig closed 9 months ago

danielnehrig commented 9 months ago

This is a Question on how to add information to a struct (which implements ToSql) which is a composite type and exists in a schema different than public given I have added a composite type to my database with a schema name different than public like "myschema"."SomeCompositeType"

#[derive(ToSql)]
struct SomCompositeType {
  value: i32,
}

now I wanna do a DB function call and pass the parameters to this DB function call

...
let data = SomeCompositeType::default();
client.execute("SELECT insert_some_composite_type($1);". &[&data]);
...

but nowhere I have given information that this struct/composite type only exists in one schema

how can I accomplish that?

maybe I've missed a section in the docs.rs but I couldn't find any information about it if there is information about it a pointer would be appreciated and a sorry in advance is given

sfackler commented 9 months ago

The generated code doesn't check the schema. You shouldn't need to do anything.