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

Diesel print-schema cannot properly generate multiple joinable! #1772

Closed
sackery opened this Issue Jul 3, 2018 · 1 comment

Comments

Projects
None yet
2 participants
@sackery

sackery commented Jul 3, 2018

This is my comments schema:

CREATE TABLE users (
  id        SERIAL PRIMARY KEY,
  name      VARCHAR(50)  NOT NULL UNIQUE,
  mail      VARCHAR(100) NOT NULL UNIQUE,
..........
);

CREATE TABLE node (
  id        BIGSERIAL PRIMARY KEY,
  uid       INTEGER      NOT NULL DEFAULT -1 REFERENCES users (id) ON DELETE CASCADE,
........
);

CREATE TABLE comments (
  id      BIGSERIAL PRIMARY KEY,
  nid     BIGINT    NOT NULL REFERENCES node (id) ON DELETE CASCADE DEFERRABLE,
  uid     INTEGER   NOT NULL REFERENCES users (id) ON DELETE CASCADE DEFERRABLE,
  pid     BIGINT    NOT NULL      DEFAULT 0 REFERENCES comments (id) ON DELETE CASCADE DEFERRABLE,
  at      INTEGER REFERENCES users (id),
  likes   INTEGER   NOT NULL      DEFAULT 0,
  body    TEXT      NOT NULL,
  created TIMESTAMP NOT NULL      DEFAULT now(),
  changed TIMESTAMP NOT NULL      DEFAULT now()
);

and the print-schema just generated one joinable~:

joinable!(comments -> node (nid));
// joinable!(comments -> users (uid)); this cannot be auto generated.
@weiznich

This comment has been minimized.

Contributor

weiznich commented Jul 6, 2018

I've tried to reproduce this locally using the provided schema and failed to reproduce this.

$ diesel print-schema
table! {
    comments (id) {
        id -> Int8,
        nid -> Int8,
        uid -> Int4,
        pid -> Int8,
        at -> Nullable<Int4>,
        likes -> Int4,
        body -> Text,
        created -> Timestamp,
        changed -> Timestamp,
    }
}
table! {
    node (id) {
        id -> Int8,
        uid -> Int4,
    }
}
table! {
    users (id) {
        id -> Int4,
        name -> Varchar,
        mail -> Varchar,
    }
}
joinable!(comments -> node (nid));
joinable!(node -> users (uid));
allow_tables_to_appear_in_same_query!(
    comments,
    node,
    users,
);
$ diesel --version
diesel 1.3.1

Closed because this does not seem to be a issue.
(Feel free to add more informations how to reproduce this, but without any idea how to reproduce this there is nothing we can do here.)

@weiznich weiznich closed this Jul 6, 2018

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment