Join GitHub today
GitHub is home to over 28 million developers working together to host and review code, manage projects, and build software together.
Sign upAssociations with changed-column names as foreign key #825
Comments
This comment has been minimized.
|
I can confirm that this issue is still present. Given this struct: struct Foo {
#[column_name(barId)]
bar_id: i32,
}There is no way to define We need to change the derive to:
|
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
ggrochow commentedMar 23, 2017
•
edited
I am working on an application for use on an existing database, that uses mostly camelCased names instead of snake_cased. I would obviously like to unify the naming to be all snake_cased for use in rust, which I can do using
#[column_name(...)], however combined withforeign_keyits causing me some issues with associations.This gist contains a working version of my code, that compiles and prints out what I expect it to. Custom schema derives since I have some columns named
typeIf you look at line 59 of main you can see im using
companyIdinstead of the more rust-likecompany_idAttempting to remedy this is where my error occurs.
changing it to
#[column_name(companyId)] company_id: i64,produces this error:
Makes sense, since I've removed that, so I update the
belongs_toofAdministratorto be#[belongs_to(Company, foreign_key="company_id")]to reflect the new-name.Buuuuut now it produces a large error-pile complaining about full error gist here
Using the following versions
rustc 1.16.0 (30cf806ef 2017-03-10)
diesel/diesel_codegen - version 0.12.0, with mysql
Is this a bug? or am I just attempting to accomplish this in the incorrect way?
Also does there exist some sort of page/repository of these not super helpful compiler errors, that will help me understand them a little better? or anything I should dig into for trying to figure it out on my own. Would a better understanding of the derive / proc macro system help? or are these just errors as confusing to others as well?