[JDBC-50] insert-rows (incorrectly) patches incomplete records Created: 21/Mar/13 Updated: 01/Jun/16 Resolved: 06/Apr/13
|Reporter:||Cees van Kemenade||Assignee:||Sean Corfield|
Postgres database on Debian machine
When using sql/insert-rows with a dataset that contains incomplete rows the rows will be patched with values from the preceding rows. The behaviour to be expected is not documented.
I would expect insert-rows either only accepts complete rows. When accepting incomplete rows I would expect patching with nil-values instead of values from other rows.
Attached you find an example and the output when running in comments.
|Comment by Sean Corfield [ 06/Apr/13 3:10 PM ]|
This looks like an old / long-standing bug that no one has run into before.
In the new (soon-to-be 0.3.0) release, (clojure.java.jdbc.sql/insert :table [1 1]  ) would throw an exception:
IllegalArgumentException insert called with inconsistent number of columns / values clojure.java.jdbc.sql/insert-multi-row (sql.clj:116)
I will update clojure.java.jdbc/insert-rows to throw a similar exception.
|Comment by Sean Corfield [ 06/Apr/13 3:38 PM ]|
Fixed in 0.3.0-SNAPSHOT by throwing an exception if the value-groups are not all the same length.
Currently relies on the DB to trap column names not matching value groups (which is known not to work on SQLite but does work on other DBs as far as I know).
insert-rows is deprecated in 0.3.0 - use insert! instead going forward (which does more validation).