This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2017-03-02
Channels
- # aws-lambda (1)
- # beginners (28)
- # boot (54)
- # cider (11)
- # clara (28)
- # cljs-dev (74)
- # cljsrn (13)
- # clojure (342)
- # clojure-austin (3)
- # clojure-dusseldorf (4)
- # clojure-france (2)
- # clojure-greece (11)
- # clojure-italy (42)
- # clojure-poland (7)
- # clojure-russia (11)
- # clojure-spec (44)
- # clojure-uk (156)
- # clojure-ukraine (4)
- # clojurescript (102)
- # cursive (17)
- # datascript (19)
- # datomic (17)
- # dirac (39)
- # emacs (22)
- # funcool (56)
- # hoplon (25)
- # jobs (3)
- # jobs-discuss (31)
- # leiningen (2)
- # luminus (4)
- # lumo (3)
- # off-topic (47)
- # om (51)
- # onyx (57)
- # re-frame (13)
- # reagent (57)
- # remote-jobs (15)
- # ring (9)
- # ring-swagger (7)
- # robots (2)
- # rum (6)
- # specter (16)
- # sql (7)
- # test-check (37)
- # untangled (7)
- # yada (5)
hello everyone, im new to clojure and the JVM in general...
i have an existing database, which is, unfortunately full of triggers ..
i have a field (phone region prefix) which isnt optional ( you have to provide a value ), but there are triggers that calculate those values and input them for me
if i try to make a insert statement on the mysql CLI, everything goes fine, but when i try to run it via JDBC I get an java exception
java.sql.SQLException: field 'ddd' doesn't have a default value
is there a way to mimic the CLI behaviour?
(defn create-usuer
[^String email ^String phone ^String username ^String cpf]
(jdbc/insert! db :tb_usuario {:tipo "p"
:logado 0
:ativo 1
:idPaisTelefone1 1
:telefone1 phone
:usuario email
:email email
:senha "hash the cpf"
:celular phone
:cpf cpf
:dataCriacao "NOW()"
:dataAtualizacao "NOW()"
:nome username}))
this is how im trying to insert itI’m surprised the insert via CLI allows you to omit ddd
given that it’s non-null and has no default value. The exception you get is exactly what I’d expect from JDBC: a non-null field with no default value has to have some value provided in the insert statement.
The triggers only fire “after” the insert so you have to satisfy that basic constraint first.
Ah, I see you also asked this in #clojure and got pointed to a forum posting as to why the CLI behavior differs...
I see you also posted to the java.jdbc mailing list, so I’ll post that forum link in response so folks have that information in the archives (thanks @hiredman )