Closed hotwoofy closed 6 years ago
The compiled SQL has two placeholders but three trailing parameters:
user=> (compile (join c k (where (= :k.permalink :c.company_permalink))) nil)
["SELECT c.*,k.* FROM company c JOIN (SELECT k.* FROM investment k WHERE (k.type = ?)) AS k ON (k.permalink = c.company_permalink) WHERE (c.name = ?)" "angel" "angel" "MongoDB"]
The problem is somewhere inside the clojureql.core/compile
method where the environment is being assembled. I expect it should be producing only one parameter of "angel" rather than two.
https://github.com/LauJensen/clojureql/blob/master/src/clojureql/sql92compiler.clj#L116 and https://github.com/LauJensen/clojureql/blob/master/src/clojureql/sql92compiler.clj#L118 are both contributing (nil "angel" nil)
which gets flattened down and nils removed
Thanks for posting. Pushed a fix.
We're running the following code, and noticing that in both cases of join ordering, the contents of the where expression is overridden.
We would expect: