Fork me on GitHub
#luminus
<
2016-08-05
>
jmayaalv14:08:01

do i need to do something special to use hugsql snippets with conman? Parameters are never passed to the snippet. Debugging found that db connection is passed instead the parameters map.

jmayaalv15:08:21

this is the state on sqlvec-fn* when calling a snippet (search-snip {:tenant-id 1698}):

Class: clojure.lang.PersistentArrayMap
Contents: 
  0. [ psql [ "FROM   trd_product p, trd_contract c\nWHERE  p.productid = c.productid AND\n       p.tenantid = " { :type :v, :name :tenant-id } ] ]
  1. [ options {} ]
  2. [ y [email protected] ]
  3. [ param-data { :datasource HikariDataSource (HikariPool-21) } ]
  4. [ opts { :tenant-id 1698 } ]

curtis.summers15:08:20

@jmayaalv That definitely looks like a bug, because sqlvec functions should not take a db connection at all.

curtis.summers15:08:01

Ah, maybe it is the usage of sqlvec function vs a :snip. Conman should handle snippets just fine. How is search-snip defined in your SQL file?

jmayaalv15:08:04

this is the snippet:

-- :snip search-snip
FROM   trd_product p, trd_contract c
WHERE  p.productid = c.productid AND
       p.tenantid = :tenant-id

curtis.summers15:08:09

It might be worth putting this in as a bug so we can get to the bottom of it. HugSQL passes metadata along indicating that the function is a snippet, and conman uses that to handle snippets differently. Feel free to put in an issue on HugSQL, and we'll try to reproduce the issue: https://github.com/layerware/hugsql/issues

jmayaalv15:08:24

btw, Thank you for Hugsql πŸ™‚ It’s great πŸ™‚

curtis.summers15:08:35

You're welcome! πŸ™‚

jmayaalv15:08:53

a work around is to call: (edge-ui.db.core/search-snip {:tenant-id 1698} nil)

jmayaalv15:08:23

the output is: ["From trd_product p, trd_contract c\nWHERE p.productid = c.productid AND\n p.tenantid = ?" 1698]