Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Snippets sqlvec fns take a connection instead of parameters map when using Conman #50

Closed
jmayaalv opened this issue Aug 5, 2016 · 7 comments

Comments

@jmayaalv
Copy link

jmayaalv commented Aug 5, 2016

A "Parameter Mismatch" exception is thrown when calling snippets that receive parameters when using Conman.

snippet:

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

(search-snip {:tenant-id 1698})

This is the state of sqlvec-fn* when debugging:

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 hugsql.core$sqlvec_fn_STAR_$y__64066@2084d943 ]
  3. [ param-data { :datasource HikariDataSource (HikariPool-21) } ]
  4. [ opts { :tenant-id 1698 } ]
@jmayaalv
Copy link
Author

jmayaalv commented Aug 5, 2016

As a workaround the snippet can be built using:
(edge-ui.db.core/search-snip {:tenant-id 1698} nil)

@csummers
Copy link
Member

csummers commented Aug 5, 2016

Thanks for the report.
What are your HugSQL and conman versions?

@jmayaalv
Copy link
Author

jmayaalv commented Aug 5, 2016

conman "0.5.8"
hugsql "0.4.7"

@csummers
Copy link
Member

csummers commented Aug 5, 2016

You know, I think this may have been an issue since the beginning of conman+HugSQL and we just didn't catch it until now.

It looks like conman is missing a :meta on this line.

It is currently:

#(-> % second :snip? boolean)

but should be:

#(-> % second :meta :snip? boolean)

Pinging @yogthos on this. I'll create a conman pull request.

@yogthos
Copy link
Contributor

yogthos commented Aug 5, 2016

Awesome, thanks!

@csummers
Copy link
Member

csummers commented Aug 5, 2016

For history's sake, I found the original issue where we put this in, and it really was at the beginning!

Thanks for helping out, @jmayaalv.

@csummers csummers closed this as completed Aug 5, 2016
@jmayaalv
Copy link
Author

jmayaalv commented Aug 6, 2016

Thanks a lot guys! you rule!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants