Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

skip_insertion results in a compiler error #4006

Open
3 tasks done
42triangles opened this issue May 1, 2024 · 3 comments
Open
3 tasks done

skip_insertion results in a compiler error #4006

42triangles opened this issue May 1, 2024 · 3 comments

Comments

@42triangles
Copy link

42triangles commented May 1, 2024

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

  • This issue can be reproduced on Rust's stable channel. (Your issue will be
    closed if this is not the case)
  • This issue can be reproduced without requiring a third party crate
@42triangles 42triangles added the bug label May 1, 2024
@weiznich
Copy link
Member

weiznich commented May 1, 2024

Thanks for opening this bug report. This is expected behaviour given your diesel version. The skip_insertion option is not contained in any release yet. The documentation lists all supported field attributes for certain derives.

@weiznich weiznich closed this as not planned Won't fix, can't repro, duplicate, stale May 1, 2024
@42triangles
Copy link
Author

Shouldn't the error message be different at least? Because while it may not yet be supported in that version; the error message is at the very least confusing.

@weiznich
Copy link
Member

weiznich commented May 1, 2024

That's correct. Seems like we somehow accidentally backported a PR that changes the error message only. I'm happy to merge a PR that reverts that + prepares another release. 45915ac is the relevant commit

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants