-
Notifications
You must be signed in to change notification settings - Fork 8
Open
Description
Reproduction:
user2> (declare one, two)
#'user2/two
user2> (defentity one (has-many two {:fk :onid}))
#'user2/one
user2> (defentity two (pk :twid) (belongs-to one {:fk :onid}))
#'user2/two
user2> (exec-raw "create table one(id int auto_increment primary key, oname varchar);
create table two(twid int auto_increment primary key, tname varchar, onid int);")
(0)
user2> (insert one (values [{:oname "blue"} {:oname "red"} {:oname "green"}]))
{:SCOPE_IDENTITY() 3}
user2> (insert two (values [{:tname "hello" :onid 1} {:tname "world" :onid 1}]))
{:SCOPE_IDENTITY() 2}
user2> (select one (with two))
({:two [], :ONAME "blue", :ID 1} {:two [], :ONAME "red", :ID 2} {:two [], :ONAME "green", :ID 3})
user2> (sql-only (select one (with two)))
"SELECT one.* FROM one"
user2> (select two (with one))
[{:ONAME "blue", :ID 1, :ONID 1, :TNAME "hello", :TWID 1} {:ONAME "blue", :ID 1, :ONID 1, :TNAME "world", :TWID 2}]
user2> (sql-only (select two (with one)))
"SELECT two.*, one.* FROM two LEFT JOIN one ON one.id = two.onid"Metadata
Metadata
Assignees
Labels
No labels