diesel
diesel copied to clipboard
`skip_insertion` results in a compiler error
Setup
Compiling the following:
use diesel::Insertable;
#[derive(Insertable)]
struct Test {
x: f32,
#[diesel(skip_insertion)]
y: f32,
}
fn main() {
println!("Hello, world!");
}
with
[package]
name = "dieselstuff"
version = "0.1.0"
edition = "2021"
[dependencies]
diesel = "2.1.6"
Versions
- Rust: rustc 1.77.2 (25ef9e3d8 2024-04-09)
- Diesel: 2.1.6
- Database: not applicable
- Operating System Linux
Feature Flags
- diesel: none
Problem Description
It errors out with:
error: unknown attribute, expected one of `embed`, `skip_insertion`, `column_name`, `sql_type`, `treat_none_as_default_value`, `treat_none_as_null`, `serialize_as`, `deserialize_as`, `select_expression`, `select_expression_type`
--> src/main.rs:6:14
|
6 | #[diesel(skip_insertion)]
| ^^^^^^^^^^^^^^
In general, the following work (as in, they don't error out in the derive macro):
-
embed
-
column_name = ...
-
sql_type = ...
-
serialize_as = ...
-
deserialize_as = ...
-
select_expression = ...
-
select_expression_type = ...
And these don't work:
-
skip_insertion
-
treat_none_as_default_value
-
treat_none_as_null
What are you trying to accomplish?
Trying to use the Insertable
derive macro
What is the expected output?
Either that it doesn't error out, or in case that the input is incorrect, an error message that is less confusing
What is the actual output?
An error message that would suggest that the input is well formed
Are you seeing any additional errors?
No
Steps to reproduce
cargo new --bin diesel-test
, change Cargo.toml
& main.rs
appropriately, cargo +stable build
Checklist
- [X] I have already looked over the issue tracker and the discussion forum for similar possible closed issues.
- [X] This issue can be reproduced on Rust's stable channel. (Your issue will be closed if this is not the case)
- [X] This issue can be reproduced without requiring a third party crate