ibdknox/Korma — Issue #8: (with <table>) not included in FROM section of sql statement
Author: gberenfield
Created: 2011-11-04 14:06:18+00:00
State: open

What I see missing below is in the "FROM" statement.

It should read

FROM bmprdstr_sql AS boms, imitmidx_sql AS items

but the "imitmidx_sql" alias is missing.

(defentity items
(table :imitmidx_sql :items))

#'clojure.core/items
(defentity boms
(table :bmprdstr_sql :boms)
(pk :comp_item_no)
(has-many items {:fk :item_no}))
clojure.core=> clojure.core=> #'clojure.core/boms
clojure.core=>
(defentity items
(table :imitmidx_sql :items))

#'clojure.core/items
(defentity boms
(table :bmprdstr_sql :boms)
(has-many items ))
clojure.core=> clojure.core=> #'clojure.core/boms
(def kspec (->
(select* boms)
(join :right :items :items.item_no :comp_item_no)
(fields :item_no :seq_no :comp_item_no :items.item_desc_1 :items.item_desc_2 :qty_per_par :reference_1 :reference_2 :reference_3)
(order :seq_no)))
#'clojure.core/kspec
(defn kgetspec [item_no]
(exec (-> kspec
(where {:item_no [like item_no]}))))

#'clojure.core/kgetspec
clojure.core=> clojure.core=> (kgetspec "SOP-00003")
Failure to execute query with SQL:
SELECT boms.item_no, boms.seq_no, boms.comp_item_no, items.item_desc_1, items.item_desc_2, boms.qty_per_par, boms.reference_1, boms.reference_2, boms.reference_3 FROM bmprdstr_sql AS boms LEFT JOIN items ON items.item_no = boms.comp_item_no WHERE (boms.item_no LIKE ?) ORDER BY boms.seq_no DESC :: (SOP-00003)
SQLException:
Message: Invalid object name 'items'.
SQLState: S0002
Error Code: 208
nil
clojure.core=>