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

sql_name attribute in table macro result in Invalid table! syntax. #3735

Closed
3 tasks done
patrikha opened this issue Aug 9, 2023 · 1 comment
Closed
3 tasks done
Labels

Comments

@patrikha
Copy link

patrikha commented Aug 9, 2023

Setup

diesel = { version = "2.1.0", features = ["mysql", "chrono"] }

Versions

  • Rust: cargo 1.71.1 edition 2021 rustc 1.71.1
  • Diesel: 2.1.0
  • Database: MariaDB (MySQL)
  • Operating System 6.1.41-1-MANJARO TODO #1 SMP PREEMPT_DYNAMIC Tue Jul 25 09:17:30 UTC 2023 x86_64 GNU/Linux

Feature Flags

  • diesel: mysql, chrono

Problem Description

Can't use the sql_name attribute without getting a compiler error.

diesel::table! {
    sonardefects (id) {
        id -> Integer,
        #[max_length = 32]
        key -> Varchar,
        #[sql_name = "type", max_length = 32]
        type_ -> Nullable<Varchar>,
    }
}

What are you trying to accomplish?

Renaming a table column from type to type_

What is the expected output?

no compile error

What is the actual output?

error: Invalid `table!` syntax. Please see the `table!` macro docs for more info.
       Docs available at: `https://docs.diesel.rs/master/diesel/macro.table.html`
   --> src/schema.rs:842:1
    |
842 | / diesel::table! {
843 | |     sonardefects (id) {
844 | |         id -> Integer,
845 | |         #[max_length = 32]
...   |
864 | |     }
865 | | }
    | |_^
    |
    = note: this error originates in the macro `diesel::table` (in Nightly builds, run with -Z macro-backtrace for more info)

Are you seeing any additional errors?

No

Steps to reproduce

Using code block above causes the compiler to fail.

Comment out the attribute makes the code compile!

diesel::table! {
    sonardefects (id) {
        id -> Integer,
        #[max_length = 32]
        key -> Varchar,
        #[/*sql_name = "type",*/ max_length = 32]
        type_ -> Nullable<Varchar>,
    }
}

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
@patrikha patrikha added the bug label Aug 9, 2023
@weiznich
Copy link
Member

weiznich commented Aug 9, 2023

Duplicate of #3692

@weiznich weiznich marked this as a duplicate of #3692 Aug 9, 2023
@weiznich weiznich closed this as not planned Won't fix, can't repro, duplicate, stale Aug 9, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants