Fork me on GitHub
#babashka
<
2021-04-01
>
borkdude07:04:59

@richiardiandrea Maybe you are wrapping the arguments inside a vector while they should not be?

richiardiandrea15:04:24

the first param is a vector that I want to store as json, the second and third two uuids

borkdude15:04:21

can you show the entire query, not just the result from the database?

borkdude15:04:52

the vector should be saved as json?

borkdude15:04:56

let me know if this works for you

richiardiandrea15:04:28

yeah that is the goal, i initially tried with the metadata but it was spitting that error then worked around it with json/generate-string

borkdude15:04:03

show me the original query with metadata that failed please

richiardiandrea15:04:12

let me share that yeah, just a sec

borkdude15:04:17

because this should work and if not, I'ld like to know why

richiardiandrea15:04:47

this is what it is not working

(defn update-diagnostic-report-descriptors!
  [db-or-tx image]
  (let [target-report (:target-report image)
        query "UPDATE diagnostic_reports SET image_descriptors = (?::jsonb) WHERE id = ? AND version_id = ?"
        sqlvec [query
                ^{:pod.babashka.sql/write :jsonb} (:image-descriptors image)
                (:id target-report)
                (:version-id target-report)]]
    (db/execute-one! db-or-tx sqlvec)))

borkdude15:04:38

you need to write:

(with-meta (:image-descriptors image) {:pod.babashka.sql/write :jsonb} )
but in hindsight, I think I will change this, because this isn't very nice to write

borkdude15:04:09

I think I'll just offer (db/json ...) and (db/jsonb ...) that will handle this for you

richiardiandrea15:04:04

ok let me try that...and why is that the case? I actually remember that I had to wrap some of my params in a function for attaching metadata once..

richiardiandrea15:04:02

looks like that worked

richiardiandrea15:04:16

this also works

> (def v ^{:pod.babashka.sql/write :jsonb} [])
#<SciVar@28395993: []>
> (meta v)
{:pod.babashka.sql/write :jsonb}

richiardiandrea15:04:33

anyways, thank you for the hint 😄

borkdude15:04:25

yes, that works, but (meta ^{:m 1} (conj [] nil)) doesn't work so I think it's better to just offer some function that handles these details https://github.com/babashka/babashka-sql-pods/issues/31

👍 3
gdubs16:04:05

I want to use https://github.com/retro/graphql-builder with babashka. It has dependencies which use java.util.concurrent... stuff. What are my options here? Put graphql-builder in a pod? Rebuild babashka with java.util.concurrent?

gdubs17:04:25

I'd prefer to just add the necessary classes to upstream babashka. I assume the downsides are this expands the bb binary size?

borkdude17:04:26

@gdwarner You can make an issue where you request the class with some evidence that this is useful for scripting and I'll take a look

borkdude17:04:53

why does a graphql lib need java.concurrent?

borkdude17:04:04

@gdwarner I tried this myself and this is needed in clj-antlr which in turn needs the java ANTLR library which is not supported in babashka

gdubs17:04:01

That's right. And that makes sense why it wouldn't work. Thank you.

richiardiandrea18:04:18

Hi there, question about pods, is there a way to have load-pod save to a local folder? I like the structure of ~/.babashka/pods/repository/org.babashka and I would like to replicate it and then tar everything for distribution.

borkdude18:04:14

@richiardiandrea Currently not, but we could make this configurable perhaps, via some env var?

borkdude18:04:47

I'm also still conflicted between ~/.babashka and ~/.bb. In the future people might have a bb.edn there too...

borkdude18:04:02

We could also add this to bb.edn

richiardiandrea18:04:45

yeah, cause it's a bit cumbersome to download stuff manually like in this approach https://github.com/eccentric-j/idle-parens/blob/8f4142d66698adadb321ace92da9ed79bbcbcedc/resources/blog/2021-01-27-clojure-like-its-php.md#the-clojure-files Additionally, given pods are OS dependent, you would need to specify the target... Yeah specifying pods in bb.edn is a good option..what about this

{:paths ...
   :deps ...
   :pods {org.babashka/postgresql :github/version "0.0.5"}
And then
bb dump-pods <dir> <arch>

borkdude18:04:06

Yeah, something like that might work. Perhaps:

bb pods install /tmp/pods --arch ....
but then also:
{:pods {:dir "/tmp/pods" ....}}
if you want to load the pods from some specific dir

richiardiandrea18:04:51

oh yes right good idea!

richiardiandrea18:04:11

gonna open a feature request and start checking how difficult that would be to implement 😄