-
-
Notifications
You must be signed in to change notification settings - Fork 504
Closed
Labels
Description
Using a domain like this:
CREATE DOMAIN session_id AS bytea CHECK(octet_length(VALUE) = 16);
CREATE TABLE sessions (
session_id session_id NOT NULL PRIMARY KEY
);
And inserting a Vec<u8>
into it with
conn.execute("INSERT INTO sessions (session_id) VALUES ($1)", &[&session.id]).unwrap();
results in
thread '<unnamed>' panicked at 'called `Result::unwrap()` on an `Err` value: Conversion(WrongType(Other { name: "session_id", oid: 25707, kind: Simple, schema: "public" }))', src/libcore/result.rs:688
That is, rust-postgres doesn't understand that the session_id
is really a bytea
.
Perhaps rust-postgres should look up the underlying type of the domain and use it? (I understand this might be a big feature request.)
Without underlying type detection, I think what I have to do is wrap the Vec<u8>
with my own type and implement ToSql
, which could be a hassle with many domains.