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 upDiesel does not produce `belonging_to()` for structs annotated with `belongs_to` #1203
Comments
This comment has been minimized.
|
Please provide your full compiler output |
This comment has been minimized.
berkus
commented
Sep 26, 2017
|
I will send you full project repo in a bit. |
This comment has been minimized.
berkus
commented
Sep 26, 2017
|
Here's the repo: https://github.com/berkus/diesel-belongs-to-bug/blob/master/README.md steps to reproduce:
(i'm using nightly jfyi) |
This comment has been minimized.
|
I reduced your repro case to this minimal case: #[macro_use] extern crate diesel;
#[macro_use] extern crate diesel_codegen;
use diesel::prelude::*;
table! {
users {
id -> Int4,
username -> Varchar,
}
}
table! {
categories {
id -> Int4,
username -> Varchar,
}
}
#[derive(Identifiable)]
pub struct User {
pub id: i32,
pub username: String,
}
#[derive(Identifiable, Associations)]
#[table_name = "categories"]
#[belongs_to(User, foreign_key = "username")]
pub struct Category {
pub id: i32,
pub username: String,
}
fn main() {
let user = User { id: 1, username: "".into() };
let cats = Category::belonging_to(&user);
}by switching to UFCS (
You are attempting to use the field |
sgrif
closed this
Sep 26, 2017
This comment has been minimized.
berkus
commented
Sep 26, 2017
|
Thanks! |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
berkus commentedSep 25, 2017
Setup
Versions
Feature Flags
Problem Description
gives
What are you trying to accomplish?
Link two tables using the
belonging_to()What is the expected output?
Should compile at least.
What is the actual output?
Regardless of whether these tables have a foreign key relation on DB or not, there's no belonging_to() function to call.
Are you seeing any additional errors?
No. Warnings:
Steps to reproduce
models.rs as above.
schema.rs (from
diesel print-schema):Checklist