This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2016-08-20
Channels
- # alda (2)
- # beginners (6)
- # boot (25)
- # cider (10)
- # clojars (5)
- # clojure (81)
- # clojure-brasil (1)
- # clojure-dev (2)
- # clojure-russia (19)
- # clojure-spec (21)
- # clojure-uk (69)
- # clojurescript (23)
- # code-reviews (15)
- # cursive (3)
- # datavis (1)
- # datomic (8)
- # euroclojure (3)
- # events (5)
- # flambo (15)
- # hoplon (17)
- # jobs-rus (13)
- # lambdaisland (50)
- # mount (5)
- # off-topic (3)
- # om (1)
- # parinfer (72)
- # proton (1)
- # protorepl (1)
- # re-frame (17)
- # reagent (59)
- # videos (1)
Anyone got an idea how to convert postgres arrays into clojure vectors with newer versions of jdbc? (extend-protocol clojure.java.jdbc/ISQLParameter clojure.lang.IPersistentVector (set-parameter [v ^java.sql.PreparedStatement stmt ^long i] (let [conn (.getConnection stmt) meta (.getParameterMetaData stmt) type-name (.getParameterTypeName meta i)] (if-let [elem-type (when (= (first type-name) \_) (apply str (rest type-name)))] (.setObject stmt i (.createArrayOf conn elem-type (to-array v))) (.setObject stmt i v))))) the above code no longer works and it’s deep in java land, so I’m lost >_>
AbstractJdbc2Statement.java: 2746 org.postgresql.jdbc2.AbstractJdbc2Statement$BatchResultHandler/handleError QueryExecutorImpl.java: 457 org.postgresql.core.v3.QueryExecutorImpl$1/handleError QueryExecutorImpl.java: 1887 org.postgresql.core.v3.QueryExecutorImpl/processResults QueryExecutorImpl.java: 405 org.postgresql.core.v3.QueryExecutorImpl/execute AbstractJdbc2Statement.java: 2893 org.postgresql.jdbc2.AbstractJdbc2Statement/executeBatch jdbc.clj: 404 clojure.java.jdbc/execute-batch jdbc.clj: 397 clojure.java.jdbc/execute-batch jdbc.clj: 755 clojure.java.jdbc/db-do-execute-prepared-statement/fn jdbc.clj: 589 clojure.java.jdbc/db-transaction* jdbc.clj: 562 clojure.java.jdbc/db-transaction* RestFn.java: 425 clojure.lang.RestFn/invoke jdbc.clj: 754 clojure.java.jdbc/db-do-execute-prepared-statement jdbc.clj: 742 clojure.java.jdbc/db-do-execute-prepared-statement jdbc.clj: 774 clojure.java.jdbc/db-do-prepared jdbc.clj: 758 clojure.java.jdbc/db-do-prepared RestFn.java: 464 clojure.lang.RestFn/invoke jdbc.clj: 879 clojure.java.jdbc/execute!/execute-helper jdbc.clj: 884 clojure.java.jdbc/execute! jdbc.clj: 863 clojure.java.jdbc/execute! RestFn.java: 425 clojure.lang.RestFn/invoke
you likely need to call getNextException on the exception object to get the real exception
as almost all postgres exceptions really annoyingly say, "Call getNextException to see the cause"
all the exceptions in that blob you pasted say "Call getNextException to see the cause"
so a nil value is tried to be passed in for category_ref instead of the vector i tried to pass in
and it’s related to that because the insert works when i remove the column that has the vector in the code
INSERT INTO
advertisements (title, description, url, category_ref, visible_p,
our_id) VALUES ('StartShop', 'StartShop', '', 1 NULL, FALSE, -1)
it looks like you are using honeysql via ez-database, my guess is honeysql doesn't handle arrays
I don't know that much about honeysql internals, but it looks like it tries to treat all sequential collections as a cast, where the first thing is the value and the second thing is the type
hmm maybe. but i got the same version of honeysql as well. sigh… thanks for being a soundboard. got some places to dig now at least
https://github.com/jkk/honeysql/issues/85 looks like honesql uses a special reader macro for arrays
I am trying to test my API (`composure-api` + midje
) to see if it returns correct entities from “DB” (atom) for each type of request but I am very new to Clojure and don’t really understand how to override (mock) that DB in tests. How do I do that?
(def db (atom {}))
(deftest my-test
(with-redefs [db (atom {:some :values)]
(= (my-business-logic) {:some :output)))
@plexus thanks to you I found about the provided
from Midje, and it's more flexible - just FYI 🙂
Hello dear Clojure friends, I'd like to build a Full Stack Clojure web application but I get stuck with dependency injection problems. Let say I want to use a Postgresql database in my production environment but id like to swap this and use an atomic db whenever I develop. I have looked into https://github.com/stuartsierra/component but it looks like I have to build the entire application in the component/Lifecycle framework and I will live and die with it. Do you have any advice for me about that problem ? Am I getting something wrong ? I am opened for discussion about that topic !
@abolduc: Try https://github.com/tolitius/mount if you're finding component too prescriptive. I personally find it much easier to work with.
Oh I'll take a deeper look at this. I love the mount/start-with-states function, thank you @chrisjd
(def prefix-paths
"Given a coll of items, returns a coll of the prefixes of the coll."
(comp rest (partial reductions conj [])))
^ That’s reasonably idiomatic, right?hey all, I'm trying to write a leiningen plugin that uses clojure.spec - not sure how (if) I can make Leiningen use clojure 1.9?
I doubt you can
you want it to use clojure.spec just to make it easier for you to write?
@gfredericks no, I wrote another lib that uses spec and I wanted to write a leiningen plugin to support that
It's no big deal if it's not possible, just wanted to check I wasn't missing anything 🙂
brabster: not sure how familiar you are with the lein plugin architecture, but a lot of times plugins can be really thin and can execute the library code in the application jvm
if yours can be structured that way then this wouldn't be a problem presumably
that would probably work - the library turns clojure into aws cloudformation json and I want to make it easy to keep the templates in the same project as the code
brabster: it'd probably consist of adding the lib to the deps list and calling the lein run
task
Running into a point of confusion here... I'm trying to use the Specter library, including it as follows:
(ns mazes.core
"Basic tools for maze wrangling."
(:require [clojure.spec :as s]
[com.rpl.specter :as specter]))
In my code, I can call (specter/transform <whatever>)
and, although it fails because I'm doing something wrong, that function is definitely in existence. However, in the REPL, I can't seem to load the library:
user=> (load "mazes/core")
CompilerException java.lang.RuntimeException: No such var: specter/transform, compiling:(mazes/core.cljc:83:5)
Of course, it's defined right there in my project.clj:
:dependencies [[org.clojure/clojure "1.9.0-alpha10"],
[com.rpl/specter "0.12.0"]]
...what gives? I've never run into this before.
If I (require '[com.rpl.specter :as specter])
in the REPL, it returns nil
.
@amacdougall transform
is in the com.rpl.specter.macros namespace
Very strange... but that code does seem to successfully invoke transform
when I use the same namespace in a test:
com.rpl.specter$transform.invokeStatic (specter.clj:85)
com.rpl.specter$transform.invoke (specter.clj:81)
mazes.core$link.invokeStatic (core.cljc:83)
Also, is that new since 0.9.2? I have a project set to that version, and it doesn't include macros but does seem to have access to transform
and setval
.
in previous versions transform
was a function in the com.rpl.specter namespace
that changed as of 0.11.0
Ah, so ... okay, I just bumped to 0.12.0, so maybe the test env is still running the 0.9.2 version somehow. Let me see if I can kick it in the pants.
yea that sounds like the issue
Yeah, that was it. Thanks! And thanks for making such a handy library. In that previous project, I only needed a bit of it, but I expect to be hitting it pretty hard in this new one. ...and now that I've got it working in the REPL, I can start figuring out exactly what I was doing wrong...