Skip to content

Instantly share code, notes, and snippets.

@rundis
Last active August 29, 2015 14:18
Show Gist options
  • Save rundis/b035bfd058b419f782e5 to your computer and use it in GitHub Desktop.
Save rundis/b035bfd058b419f782e5 to your computer and use it in GitHub Desktop.
Find unbound weirdness
(ns acme-auth.store
(:require [clojure.java.jdbc :as jdbc]))
(defn- find-user-roles [conn user-id]
(let [id (jdbc/query conn "select sysdate from dual")]
(map (fn [row] {:role-id (:id row) :application-id (:application_id row)})
(jdbc/query conn ["select r.id, r.application_id
from role r
inner join user_role ur on r.id = ur.role_id
where ur.user_id = ?" user-id]))))
(defn add-user! [ds user]
(jdbc/with-db-transaction [conn ds]
(let [res (jdbc/insert! conn
:user
{:username (:username user) :password (:password user)})
user-id ((keyword "scope_identity()") (first res))]
(doseq [ur (:user-roles user)]
(jdbc/insert! conn
:user_role
[:user_id :role_id]
[user-id (:role-id ur)])))))
;; Position at line 5 (or 4 if zero based :) ), at j in jdbc/, find-unbound gives:
({:status [done], :id 88cb5e4f-bbee-49df-a6a2-698c0789fc56, :unbound []})
;; I would have expected conn to be in unbound
;; Positioning at line 19 (18 really) at j in jdbc/, find unbound gives:
({:status [done], :id 5241efa5-faec-4f9e-839f-e3bc9c1eeb97, :unbound [user-id conn user]})
;; I would have expected [conn user-id ur] in unbound
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment