-
I'm trying to use Example code: #[derive(Debug, Default, Queryable, Identifiable, Selectable, Insertable, Associations)]
#[diesel(table_name = crate::schema::post)]
#[diesel(belongs_to(UserRecord, foreign_key = user_id))]
#[diesel(check_for_backend(diesel::sqlite::Sqlite))]
pub struct PostRecord {
pub id: i32,
pub user_id: i32,
pub content: String,
}
#[diesel::dsl::auto_type]
fn post_select() -> _ {
post::table.select(PostRecord::as_select())
} Which gives me an On the other hand, this does work: #[diesel::dsl::auto_type]
fn post_select() -> _ {
post::table.select((post::id, post::user_id, post::content))
} But obviously using This seems like it should work to me, but maybe I'm missing something. |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 2 replies
-
The [documentation already] (https://docs.diesel.rs/2.2.x/diesel/dsl/attr.auto_type.html#limitations ) states that The workaround (provide an explicit type for this subexpression) listed in the documentation should also work here. |
Beta Was this translation helpful? Give feedback.
Selectable::as_select
is one of the functions that is not supported by#[auto_type]
so it is kind of expected to not work there. With the current limitations of what a proc-macro can do and with the current design of that function it's not possible to support it there as it has an unbounded generic type somehow needs to be specified.The [documentation already] (https://docs.diesel.rs/2.2.x/diesel/dsl/attr.auto_type.html#limitations ) states that
#[auto_type]
doesn't support all of diesels DSL, although this function is missing from the list in the documentation. We would welcome a PR to add it there.The workaround (provide an explicit type for this subexpression) listed in the documenta…