Open sveri opened 8 years ago
It is not really supported. As you can see, the query generates sql that joins topic with topic without aliasing, hence the error message:
(sql-only (select topic (with topic)))
=> "SELECT \"topic\".*, \"topic\".* FROM \"topic\" LEFT JOIN \"topic\" ON \"topic\".\"id\" = \"topic\".\"uuid\""
Other problem is that using entities the foreign key is always joined to primary key which doesn't appear to be correct according to the table definition.
I's suggest constructing the query without using entities:
(sql-only (select [:topic :parent] (join [:topic :child] (= :child.parent_topic_id :parent.uuid))))
=> "SELECT * FROM \"topic\" AS \"parent\" LEFT JOIN \"topic\" AS \"child\" ON \"child\".\"parent_topic_id\" = \"parent\".\"uuid\""
Ok, thanks for the clarification. Is it ok to leave this open as a feature request?
Sure, let's leave this open.
I am trying to model a parent child relationship with one table. This is my code:
throws this error:
Is this even supported by korma? If so, how to do it right?