Description
When a table has a composite unique key and contains at least one row, querying with a WHERE clause that matches a column value with no corresponding rows throws a NullPointerException.
Reproduction
(require '[com.wotbrew.relic :as rel])
(let [db (-> {}
(rel/mat [[:from :dashboard-var] [:unique :doc-id :scope :var-name]])
(rel/transact [:insert :dashboard-var {:doc-id "sales-q1"
:scope "overview"
:var-name "region"
:value "East"}]))]
;; This throws NPE — scope "" has no rows, but scope "overview" does
(rel/q db [[:from :dashboard-var]
[:where [= :doc-id "sales-q1"]
[= :scope ""]
[= :var-name "region"]]]))
Expected behavior
Should return an empty collection ().
Actual behavior
JVM:
Cannot invoke "clojure.lang.IFn.invoke(Object)" because "m" is null
ClojureScript:
Cannot read properties of null (reading 'cljs$core$IFn$_invoke$arity$1')
Stack trace points to com.wotbrew.relic.impl.dataflow.
Notes
- Only occurs when the table has data — querying an empty table with the same WHERE works fine.
- Only occurs with composite unique keys — single-column unique keys don't trigger this.
- The query works when all WHERE column values match at least one row.
- Workaround: query with fewer WHERE conditions and filter in Clojure.
Version
com.wotbrew/relic {:mvn/version "0.1.7"}
Description
When a table has a composite unique key and contains at least one row, querying with a WHERE clause that matches a column value with no corresponding rows throws a NullPointerException.
Reproduction
Expected behavior
Should return an empty collection
().Actual behavior
JVM:
ClojureScript:
Stack trace points to
com.wotbrew.relic.impl.dataflow.Notes
Version
com.wotbrew/relic {:mvn/version "0.1.7"}