   (j/query db query))
 
 (def query q)
+
 (def qm
   (memoize q))
+
 (defn s
   [t]
   (q (str "select * from " t)))

      query-get-foreign-key-sql
      " WHERE FK.TABLE_NAME = '" t "'")))

(defn query-get-primary-key
  [t]
  (qm (str

  [t]
  (not (is-entity? t)))

(defn sw-get-foreign-key
  [t col]
  (first (filter (fn [fk] (= (:fk_column fk) col)) (query-get-constraints t))))

(defn walk-database
  [start-t]
  (let [already-walked (transient [])
        inserted-values (transient {})]
    (defn walk-table
      [t]
      (defn get-inserted-value
        "Retrieves the primary key of an inserted entity"
        [t]
        (print "get-inserted-value " t nl))

      (defn get-lookup-value
        [t]
        (print "get-lookup-value " t nl))

      (defn query-get-parent-table
        [t col]
        (print "query-get-parent-table " t col nl))

      (defn get-lookup-value
        [t]
        (print "get-lookup-value " t nl))
      (defn deal-with-primitive
        [t col]
        (print "deal with primitive " t col nl))
      (defn deal-with-pk
        [t col]
        (print "deal with pk: " t col nl))
      (defn deal-with-fk
        [t col]
        (print "deal with fk: " t col nl)
        (let [parent (:pk_table (sw-get-foreign-key t (:column_name col)))]
          (cond
            (is-entity? parent)
            (if (.contains (persistent! already-walked) parent)
              (get-inserted-value parent)
              (walk-table parent))
            (is-lookup? t) (get-lookup-value parent))))
      (defn deal-with-col
        [col]
        (cond (is-pk? t col) (deal-with-pk t col)
              (is-fk? t col) (deal-with-fk t col)
              :else (deal-with-primitive t col)))

      (let [cols  (query-get-columns start-t)]
        (map deal-with-col cols)))
    (walk-table start-t)))


;; from https://stackoverflow.com/questions/925738/how-to-find-foreign-key-dependencies-in-sql-server
;;   SELECT
