Skip to content

Korma 0.5.0-RC1 breaks "with" on many-to-many relationships #400

@AlexAti

Description

@AlexAti

With this definitions:

(defentity user
  (table :users)
  (pk :userid)
  (entity-fields :userid)
  (many-to-many role :user_roles {:lfk :userid
                                  :rfk :roleid})
  (has-many answer {:fk :userid}))

(defentity role
  (table :role)
  (pk :roleid)
  (entity-fields :roleid))

The following works with korma 0.4.3 but not with korma 0.5.0-RC1:

(select user (with role))

Also, the output of (dry-run (select user (with role))) provides the following in 0.4.3:

dry run :: SELECT "users"."userid" FROM "users" :: []
dry run :: SELECT "role"."roleid" FROM "role" INNER JOIN "user_roles" ON "user_roles"."roleid" = "role"."roleid" WHERE ("user_roles"."userid" = ?) :: [1]
=> ({:userid 1, :role [{:roleid 1}]})

but the following in 0.5.0-RC1:

dry run :: SELECT "users"."userid" FROM "users" :: []
dry run :: SELECT "role"."roleid" FROM "role" INNER JOIN "user_roles" ON () :: []
=> ({:userid 1, :role [{:roleid 1}]})

So the issue seems with how the following part is being handled:

(many-to-many role :user_roles {:lfk :userid
                                :rfk :roleid})

I haven't found anything more concrete unfortunately.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions