diff --git a/src/next/jdbc/specs.clj b/src/next/jdbc/specs.clj index a073b69..cff1cd4 100644 --- a/src/next/jdbc/specs.clj +++ b/src/next/jdbc/specs.clj @@ -126,8 +126,11 @@ (s/fdef sql/insert-multi! :args (s/and (s/cat :connectable ::connectable :table keyword? - :cols (s/coll-of keyword? :kind sequential?) - :rows (s/coll-of (s/coll-of any? :kind sequential?) :kind sequential?) + :cols (s/coll-of keyword? + :kind sequential? + :min-count 1) + :rows (s/coll-of (s/coll-of any? :kind sequential?) + :kind sequential?) :opts (s/? ::opts-map)) #(apply = (count (:cols %)) (map count (:rows %))))) diff --git a/src/next/jdbc/sql.clj b/src/next/jdbc/sql.clj index 0f1f7dc..d58a867 100644 --- a/src/next/jdbc/sql.clj +++ b/src/next/jdbc/sql.clj @@ -165,6 +165,7 @@ (assert (apply = (count cols) (map count rows)) "column counts are not consistent across cols and rows") ;; to avoid generating bad SQL + (assert (seq cols) "cols may not be empty") (assert (seq rows) "rows may not be empty") (let [table-fn (:table-fn opts identity) column-fn (:column-fn opts identity) diff --git a/test/next/jdbc/sql_test.clj b/test/next/jdbc/sql_test.clj index c15638b..ea89850 100644 --- a/test/next/jdbc/sql_test.clj +++ b/test/next/jdbc/sql_test.clj @@ -187,6 +187,10 @@ (is (thrown? clojure.lang.ExceptionInfo (sql/delete! (ds) :fruit {})))) +(deftest no-empty-columns + (is (thrown? clojure.lang.ExceptionInfo + (sql/insert-multi! (ds) :fruit [] [[] [] []])))) + (deftest no-empty-order-by (is (thrown? clojure.lang.ExceptionInfo (sql/find-by-keys (ds) :fruit