korma / Korma

Tasty SQL for Clojure.
http://sqlkorma.com
1.48k stars 222 forks source link

"missing FROM-clause" when using many to many #377

Open bennythomps opened 7 years ago

bennythomps commented 7 years ago

I have the following definitions:

(defentity permissions)
(defentity entity)
(defentity account
  (many-to-many entity))

When I try to select data using my join, it fails

(select db/account (with db/entity) (where {:id (:id user)}))

resulting in ERROR: missing FROM-clause entry for table "entity"

Here's my table definitions...

CREATE TABLE IF NOT EXISTS account (
    id bigserial  NOT NULL,
    email varchar(50)  NOT NULL,
    password varchar(256)  NULL,
    CONSTRAINT account_pk PRIMARY KEY (id)
);

CREATE TABLE IF NOT EXISTS entity (
    id bigserial NOT NULL,
    name varchar(50) NOT NULL,
    CONSTRAINT entity_pk PRIMARY KEY (id)
);

CREATE TABLE IF NOT EXISTS permissions (
    account_id bigint  NOT NULL REFERENCES account (id),
    entity_id bigint  NOT NULL REFERENCES entity (id),
    CONSTRAINT permissions_pk PRIMARY KEY (account_id,entity_id)
);

Am I doing something wrong?

venantius commented 6 years ago

I'm going through old issues and trying to clean them up. Has this issue persisted?

If there hasn't been a response to this issue in 2 weeks, I'll close the ticket.

MrEbbinghaus commented 5 years ago

I'm getting this too. :-(