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

Schema generation results in invalid decorators in 2.1 #3692

Closed
3 tasks done
thomasmost opened this issue Jul 13, 2023 · 1 comment
Closed
3 tasks done

Schema generation results in invalid decorators in 2.1 #3692

thomasmost opened this issue Jul 13, 2023 · 1 comment
Labels

Comments

@thomasmost
Copy link
Contributor

thomasmost commented Jul 13, 2023

Versions

  • Rust: 1.7.1
  • Diesel: 2.1
  • Database: MySQL
  • Operating System MacOS

Feature Flags

  • diesel: ["mysql", "extras", "chrono", "r2d2"]

Problem Description

Generating the table definitions for tables with both sql_renames of reserved words and max lengths results in a schema.rs file that won't compile

What are you trying to accomplish?

generating a table with a migration like so creates an invalid table definition in schema.rs

CREATE TABLE `my_table` (
  `id` char(36) NOT NULL,
  `type` varchar(50) NOT NULL,
  PRIMARY KEY (`id`)
);

What is the expected output?

diesel::table! {
    my_table (id) {
        #[max_length = 36]
        id -> Char,
        #[sql_name = "type"]
        #[max_length = 50]
        type_ -> Varchar,
    }
}

What is the actual output?

diesel::table! {
    offsets_bill (id) {
        #[max_length = 36]
        id -> Char,
        #[sql_name = "type", max_length = 50]
        type_ -> Varchar,
    }
}

Are you seeing any additional errors?

This causes

Invalid table!syntax. Please see thetable! macro docs for more info.

Steps to reproduce

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
@thomasmost thomasmost added the bug label Jul 13, 2023
@weiznich
Copy link
Member

Duplicate of #3681

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