Rust Version
1.94.0
Diesel Version
2.3.7
Diesel Features
postgres uuid
Database Version
PostgreSQL 18.3
Operating System Version
Artix Linux x86_64, up to date
What happened?
Minimal example that can be used to reproduce this:
Schema:
pub mod sql_types {
#[derive(diesel::query_builder::QueryId, Clone, diesel::sql_types::SqlType)]
#[diesel(postgres_type(name = "user"))]
pub struct User;
}
diesel::table! {
use diesel::sql_types::*;
use super::sql_types::User;
foo (id) {
id -> Uuid,
users -> Array<Nullable<User>>,
content -> Text,
}
}
Models:
#![allow(unused)]
#![allow(clippy::all)]
use crate::schema::{
self,
foo,
};
use uuid::Uuid;
use diesel::prelude::*;
#[derive(Debug, Clone, diesel::FromSqlRow, diesel::AsExpression)]
#[diesel(sql_type = schema::sql_types::User)]
pub struct User {
pub username: String,
pub password: String,
}
#[derive(Queryable, Debug, Identifiable, Selectable, Insertable)]
#[diesel(table_name = foo)]
pub struct FooEntry {
pub id: Uuid,
pub users: Vec<Option<User>>,
pub content: String,
}
lib.rs:
mod models;
mod schema;
use diesel::prelude::*;
fn my_func(conn: &mut PgConnection, foo: models::FooEntry) {
diesel::insert_into(schema::foo::table)
.values(&foo)
.returning(models::FooEntry::as_returning())
.get_result(conn)
.unwrap();
}
Cargo.toml for this example:
[package]
name = "diesel_issue"
version = "0.1.0"
edition = "2024"
[dependencies]
diesel = { version = "2.3", features = ["postgres", "uuid"] }
uuid = "1.22"
ToSql and FromSql need to be manually implemented for the User model. They have not been manually implemented in this example, so an error is expected, but this causes the compiler error:
Compiling diesel_issue v0.1.0 (/home/laura/git/mine_temp/diesel_issue)
error[E0275]: overflow evaluating the requirement `_: Sized`
--> src/lib.rs:10:10
|
10 | .get_result(conn)
| ^^^^^^^^^^
|
= help: consider increasing the recursion limit by adding a `#![recursion_limit = "256"]` attribute to your crate (`diesel_issue`)
= note: required for `DefaultableColumnInsertValue<ColumnInsertValue<users, Bound<Array<...>, ...>>>` to implement `QueryFragment<_>`
= note: 123 redundant requirements hidden
= note: required for `DefaultableColumnInsertValue<ColumnInsertValue<users, Bound<Array<...>, ...>>>` to implement `QueryFragment<_>`
= note: required for `DefaultableColumnInsertValue<ColumnInsertValue<users, Bound<Array<...>, ...>>>` to implement `InsertValues<_, table>`
= note: 3 redundant requirements hidden
= note: required for `InsertStatement<table, ValuesClause<(..., ..., ...), ...>, ..., ...>` to implement `QueryFragment<_>`
= note: required for `InsertStatement<table, ValuesClause<(..., ..., ...), ...>, ..., ...>` to implement `LoadQuery<'_, _, _>`
note: required by a bound in `get_result`
--> /home/laura/.cargo/registry/src/index.crates.io-1949cf8c6b5b557f/diesel-2.3.7/src/query_dsl/mod.rs:1776:15
|
1774 | fn get_result<'query, U>(self, conn: &mut Conn) -> QueryResult<U>
| ---------- required by a bound in this associated function
1775 | where
1776 | Self: LoadQuery<'query, Conn, U>,
| ^^^^^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `RunQueryDsl::get_result`
= note: the full name for the type has been written to '/home/laura/git/mine_temp/diesel_issue/target/debug/deps/diesel_issue-ba21453b93f9833b.long-type-1854442447241316390.txt'
= note: consider using `--verbose` to print the full type name to the console
Adding the following impls to the models leads the code to be able to compile:
impl ToSql<schema::sql_types::User, diesel::pg::Pg> for User {
fn to_sql<'b>(
&'b self,
out: &mut diesel::serialize::Output<'b, '_, diesel::pg::Pg>,
) -> diesel::serialize::Result {
todo!()
}
}
impl FromSql<schema::sql_types::User, diesel::pg::Pg> for User {
fn from_sql(
bytes: <diesel::pg::Pg as diesel::backend::Backend>::RawValue<'_>,
) -> diesel::deserialize::Result<Self> {
todo!()
}
}
What did you expect to happen?
To have an error other than an overflow/recursion limit error. To have an error reflecting what the programmer needs to implement to fix the compiler error.
Additional details
No response
Steps to reproduce
Code is above. I've also uploaded my example to a repo here: https://git.revsuine.xyz/revsuine/diesel_issue
Although I can't guarantee that repo won't be deleted in future, the relevant code is also in this issue.
Compile time error
cargo build:
Compiling diesel_issue v0.1.0 (/home/laura/git/mine_temp/diesel_issue)
error[E0275]: overflow evaluating the requirement `_: Sized`
--> src/lib.rs:10:10
|
10 | .get_result(conn)
| ^^^^^^^^^^
|
= help: consider increasing the recursion limit by adding a `#![recursion_limit = "256"]` attribute to your crate (`diesel_issue`)
= note: required for `DefaultableColumnInsertValue<ColumnInsertValue<users, Bound<Array<...>, ...>>>` to implement `QueryFragment<_>`
= note: 123 redundant requirements hidden
= note: required for `DefaultableColumnInsertValue<ColumnInsertValue<users, Bound<Array<...>, ...>>>` to implement `QueryFragment<_>`
= note: required for `DefaultableColumnInsertValue<ColumnInsertValue<users, Bound<Array<...>, ...>>>` to implement `InsertValues<_, table>`
= note: 3 redundant requirements hidden
= note: required for `InsertStatement<table, ValuesClause<(..., ..., ...), ...>, ..., ...>` to implement `QueryFragment<_>`
= note: required for `InsertStatement<table, ValuesClause<(..., ..., ...), ...>, ..., ...>` to implement `LoadQuery<'_, _, _>`
note: required by a bound in `get_result`
--> /home/laura/.cargo/registry/src/index.crates.io-1949cf8c6b5b557f/diesel-2.3.7/src/query_dsl/mod.rs:1776:15
|
1774 | fn get_result<'query, U>(self, conn: &mut Conn) -> QueryResult<U>
| ---------- required by a bound in this associated function
1775 | where
1776 | Self: LoadQuery<'query, Conn, U>,
| ^^^^^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `RunQueryDsl::get_result`
= note: the full name for the type has been written to '/home/laura/git/mine_temp/diesel_issue/target/debug/deps/diesel_issue-ba21453b93f9833b.long-type-1854442447241316390.txt'
= note: consider using `--verbose` to print the full type name to the console
Checklist
Rust Version
1.94.0
Diesel Version
2.3.7
Diesel Features
postgres uuid
Database Version
PostgreSQL 18.3
Operating System Version
Artix Linux x86_64, up to date
What happened?
Minimal example that can be used to reproduce this:
Schema:
Models:
lib.rs:Cargo.tomlfor this example:ToSqlandFromSqlneed to be manually implemented for theUsermodel. They have not been manually implemented in this example, so an error is expected, but this causes the compiler error:Adding the following impls to the models leads the code to be able to compile:
What did you expect to happen?
To have an error other than an overflow/recursion limit error. To have an error reflecting what the programmer needs to implement to fix the compiler error.
Additional details
No response
Steps to reproduce
Code is above. I've also uploaded my example to a repo here: https://git.revsuine.xyz/revsuine/diesel_issue
Although I can't guarantee that repo won't be deleted in future, the relevant code is also in this issue.
Compile time error
cargo build:Checklist
I have already looked over the issue tracker and the discussion forum for similar possible closed issues.
This issue can be reproduced on Rust's stable channel. (Please submit the issue in the Rust issue tracker instead if that's not the case)
This issue can be reproduced without requiring a third party crate