Fork me on GitHub
#sql
<
2021-12-13
>
seancorfield03:12:50

@roguas That's just how the camel-snake-kebab library works: https://clj-commons.org/camel-snake-kebab/

👍 1
rmxm11:12:46

Thanks Sean, yeah is there easy way to provide fn to just convert one string to something predictable for me. Honestly this is a weird choice by the library, I think most people's intuition wouldnt be to modify value in this way.

seancorfield17:12:17

It is a very considered, deliberate choice by the library. You are free to use whatever builder you want, however, to achieve whatever naming choices you want.

seancorfield03:12:42

(this is another reason why I stick to the default behavior in next.jdbc)

danieroux23:12:15

Well this is fun:

Execution error (SQLFeatureNotSupportedException) at software.amazon.timestream.jdbc.TimestreamPreparedStatement/setObject (TimestreamPreparedStatement.java:365).
Parameters are not supported.
It seems my only choice is to interpolate the SQL string before sending it off? Does next.jdbc have any support for this (truly unnecessary) situation?

seancorfield23:12:03

@danie Well, you can invoke the functions with ["SQL string"] and have no parameters in there. Depending on what method actually threw that error, that may let you at least send SQL via that JDBC driver...

seancorfield23:12:26

(looks like setObject() -- so if you don't pass parameters, that should not be called)

danieroux23:12:12

@seancorfield I can confirm that a plain next.jdbc/execute! works. Now I want to hugsql that query and parameterise it.

seancorfield23:12:07

If you parameterize it, you'll cause setObject() to be called and that is not supported by that JDBC driver (which terrifies me, to be honest: a JDBC driver that does not properly support parameterized queries is a security nightmare).

danieroux23:12:23

The Timestream JDBC driver is … not good. It just flat out does not support parameterized queries.

danieroux23:12:40

(defn interpolate-the-parameters
  [sql-params]
  (reduce
    (fn interpolate-param
      [query param]
      (clojure.string/replace-first query "?" param))
    (first sql-params)
    (rest sql-params)))

(deftype TimestreamParameterDealing
  [ds]
  p/Executable
  (-execute-all
    [_this sql-params opts]
    (p/-execute-all ds [(interpolate-the-parameters sql-params)] opts)))

1