-
-
Notifications
You must be signed in to change notification settings - Fork 1.1k
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
Associations with changed-column names as foreign key #825
Comments
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:
|
Has there been any updates on this? I just ran into the same issue. |
Hi guys, do we have any updates on it ? Or maybe some one found good workaround for it ? |
For me worked: |
without the double quotes around {parent_id_from_schema}, it worked for me. I.e.: #[diesel(belongs_to(PARENT_STRUCT_NAME, foreign_key = FIELD_NAME))] see the doc |
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_key
its 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
type
If you look at line 59 of main you can see im using
companyId
instead of the more rust-likecompany_id
Attempting to remedy this is where my error occurs.
changing it to
produces this error:
Makes sense, since I've removed that, so I update the
belongs_to
ofAdministrator
to 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?
The text was updated successfully, but these errors were encountered: