LauJensen / clojureql

ClojureQL is superior SQL integration for Clojure
https://clojureql.sabrecms.com
Eclipse Public License 1.0
285 stars 39 forks source link

inserting default values #129

Closed tdrgabi closed 12 years ago

tdrgabi commented 12 years ago

Don't know how to insert into a table with a default value (ID - sequence).

Issue described here: http://stackoverflow.com/questions/9443607/how-to-insert-a-default-value-into-a-column-using-clojureql

tdrgabi commented 12 years ago

Looking through clojureql/test.clj I noticed that you do have default values.

The only difference from the code in the test and my code is that I don't define the table inside clojure but get the table schema from postgresql

tdrgabi commented 12 years ago

After some debugging in clojureql I got it down to "exec-prepared" failing.

Then I realized it's a rights issue inside the db, not related to clojureql. I have rights to insert into the table but I don't have the rights to use the sequence that postgresql uses to generate new keys.

(let [retr (.execute stmt)] crashes with "Execution aborted" and no other information I think this is a swank/clojure issue and if I run the code outside swank I might get the exception. Haven't tried.

Adding a try catch inside exec-prepared will catch & print the exception (wrong permission in my case). This might be an issue with clojureql&swank in general since lots of the exceptions will just show "Evaluation aborted" instead of a debugger&stacktrace.

My patch to see the exception: http://pastebin.com/uXZFDZ9u