Skip to content
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

select bloh with belongs-to works, select blah with has-many does not. #5

Open
zilti opened this issue Jan 10, 2013 · 0 comments
Open

Comments

@zilti
Copy link

zilti commented Jan 10, 2013

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"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant