sfackler / rust-postgres

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

Declaring types belonging to a different schema #1038

Closed deven96 closed 1 year ago

deven96 commented 1 year ago

Given the following mood enum

CREATE TYPE "mood" AS ENUM (
 'sad',
 'ok',
 'happy'
);
use postgres_types::{ToSql, FromSql};

#[derive(Debug, ToSql, FromSql)]
 #[postgres(name = "mood")]
enum Mood {
     #[postgres(name = "sad")]
     Sad,
     #[postgres(name = "ok")]
     Ok,
     #[postgres(name = "happy")]
     Happy,
 }

But I wanted to declare an enum in a different schema e.g a

CREATE TYPE types.mood AS ENUM (
 'sad',
 'ok',
 'happy'
)

How would this be represented using the #[postgres(...)] enum, as I see the Overrides struct only allows name and transparent being set?

sfackler commented 1 year ago

IIRC the implementation doesn't currently check the schema name. You shouldn't need to do anything special.

danielnehrig commented 9 months ago

IIRC the implementation doesn't currently check the schema name. You shouldn't need to do anything special.

i have a similar case with https://github.com/sfackler/rust-postgres/issues/1083 does that mean that it will check any schema with that type ?