Recursive belongs-to (parent child relationship)

25 views
Skip to first unread message

Sven Richter

unread,
Aug 3, 2015, 4:16:40 AM8/3/15
to Korma
Hi,

I am trying to model a parent child relationship with one table.
This is my code:

CREATE TABLE topic (
id INTEGER CONSTRAINT PK_TOPIC PRIMARY KEY AUTOINCREMENT NOT NULL,
parent_topic_id VARCHAR(43),
name VARCHAR(255) UNIQUE NOT NULL,
uuid VARCHAR(43) NOT NULL,
FOREIGN KEY (parent_topic_id) REFERENCES topic(uuid))

(defentity topic
(belongs-to topic {:fk :uuid}))

(defn get-all-topics [] (select topic (with topic)))

Executing get-all-topics throws this exception:
SQLException [SQLITE_ERROR] SQL error or missing database (ambiguous column name: main.topic.id) org.sqlite.core.DB.newSQLException (DB.java:890)

Is this even supported by korma? If so, how to do it right?

Thanks,
Sven

Reply all
Reply to author
Forward
0 new messages