Replies: 3 comments 2 replies
-
There is a complete draft of a guide explaining this topic (and other stuff) here in the repo: https://github.com/diesel-rs/diesel/tree/master/examples/postgres/custom_arrays#custom-array-and-data-types-in-postgres Otherwise it just seems that you don't correctly handle the conversion for your That written: It's currently hard to read your question as the formatting is off. You might want to fix that and also include the complete compiler error (as emitted by rustc) instead of only truncated versions if you look for further help.
See the examples in the getting started guide for an explanation how to use that derive. |
Beta Was this translation helpful? Give feedback.
-
Perhaps I'm somehow using compiler flags incorrectly to output compilation errors, but I didn't notice a significant difference or any special clues about what's wrong with the type. What is there Can you also please tell me how to understand when to choose one of the signature implementations in the 'Implementations on Foreign Types' section for ToSql, FromSql traits? In the examples you provided there was only general information about what these traits do |
Beta Was this translation helpful? Give feedback.
-
Issue was in the compiler settings, not in diesel. Sorry for bothering you with a problem unrelated to your library |
Beta Was this translation helpful? Give feedback.
-
Hello.
I'am trying to use Enums with Diesel(postgres), but I'am stuck with serializing(Diesel ORM -> Postgres Types and via verse). Found this 1 example in master and 2.2.x branches and few similar questions, but it didn't help me. Could you please help with next errors in code and answer on questions:
#[derive(Selectable)] + #[diesel(check_for_backend(postgres_backend))]
(did I correctly indicate the name of the backend in parentheses as 'postgres_backend'?). I don't see any difference in the wrong types error output between[derive(Selectable)] + #[diesel(check_for_backend(postgres_backend))]
and[derive(Queryable)]
I have:
models.rs
schema.rs
// @generated automatically by Diesel CLI.
up migration
-- Your SQL goes here
CREATE TYPE role_type AS ENUM ('mr', 'batrak', 'r');
CREATE TYPE sex_type AS ENUM (0, 1);
CREATE TABLE gql_entity (
id SERIAL PRIMARY KEY,
name VARCHAR NOT NULL UNIQUE,
project VARCHAR NOT NULL,
role role_type NOT NULL,
sex sex_type NOT NULL
)
and few methods that raises errors
in
have error:
error[E0277]: the trait bound (Integer, diesel::sql_types::Text, diesel::sql_types::Text, RoleType, SexType): load_dsl::private::CompatibleType<SelectEntity, _> is not satisfied
--> src\db\db_connection.rs:35:35
|
35 | .load::(&mut self.connection)
| ---- ^^^^^^^^^^^^^^^^^^^^ the trait load_dsl::private::CompatibleType<SelectEntity, > is not implemented for (Integer, diesel::sql_types::Text, diesel::sql_types::Text, RoleType, SexType), which is required by table: LoadQuery<', _, SelectEntity>
in
have error:
is not satisfiederror[E0277]: the trait bound &NewEntity<'>: diesel::Insertable
--> src\db\db_connection.rs:28:21
|
28 | .values(&new_entity)
| ------ ^^^^^^^^^^^ the trait diesel::Insertable
Beta Was this translation helpful? Give feedback.
All reactions