diesel-rs/diesel

Diesel not generate joinable when there are 2 foreign keys reference same field

kakalos12 opened this issue · 1 comments

Setup

Versions

  • **Rust: 1.75
  • **Diesel: diesel-cli 2.1.1
  • **Database: mysql
  • **Operating System : Macos 14.2.1

Feature Flags

  • diesel:

Problem Description

-- Your SQL goes here
CREATE TABLE users (
    id int unsigned not null auto_increment , 
    username varchar(32) not null,
    password varchar(72) not null,
    email varchar(255) not null,
    full_name varchar(32),
    role enum ('admin', 'ketoan' , 'general_distributor' , 'distributor' , 'sale') not null,
    ref_code char(16),
    status enum('active', 'disabled') not null default 'active',
    created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
    updated_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
    primary KEY (id),
    unique(username),
    unique(email)
);

create table user_manager(
    id int unsigned not null auto_increment,
    user_id int unsigned not null,
    manager_id int unsigned not null,
    primary key (id),
    foreign key (manager_id) references users(id),
    foreign key (user_id) references users(id)
)

Diesel cli not generate joinable for table user_manager for this code.

What are you trying to accomplish?

Diesel cli generate joinable for table user_manager.

What is the expected output?

What is the actual output?

Are you seeing any additional errors?

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

Duplicate of #3856 (Also it's expected behavior)