[honeysql "0.9.0"]
and [nilenso/honeysql-postgres "0.2.3"]
I managed to get around it. If I keyword the number, it’s inlined:
(-> (pg-helpers/create-table :cities)
(pg-helpers/with-columns [[:city (sql/call :varchar :80) (sql/call :primary-key)]
[:location :point]])
sql/format)
`
[“CREATE TABLE cities (city varchar(80) PRIMARY KEY, location point)“]
I don’t :refer :all
, maybe that has something to do with it:
;; SQL machinery
[honeysql.core :as sql]
[honeysql.helpers :as sql-helpers]
[honeysql.format :as sql-format]
[honeysql-postgres.format :as pg-format]
[honeysql-postgres.helpers :as pg-helpers]
[clj-postgresql.core :as pg]
[clojure.java.jdbc :as jdbc]
`@henrik So it may be a difference between HoneySQL 0.6.3 which is the default for honeysql-postgres and HoneySQL 0.9.0 which you're using.
Yes, confirmed: HoneySQL 0.2.3 inlines numeric parameters but HoneySQL 0.9.0 lifts them out as separate parameters.
@michaelblume Do you know if there is a way to tell HoneySQL "inline this -- it's not a parameter"?
@seancorfield I don’t think there is right now
@michaelblume I'm curious as to why it doesn't inline the keyword value -- and wondering whether that's a "safe" workaround?
I was a bit surprised that 0.2.3 inlined numeric values but lifted strings -- later versions lift numeric values to parameters.
aha, I see the problem
we’re treating numbers as parameterized values because otherwise NaN, -Infinity, and Infinity will insert badly
change introduced in 0.7.0
And that's good -- otherwise we'd get ["SELECT * FROM foo WHERE id = 123"]
which would not benefit from parameterization for different id
values.
(you want the prepared statement to have ...WHERE id = ?
so it can be reused for other values)
right
so maybe we need to introduce an Inline record type
that you could wrap the 80 in
Yeah. Keyword seems to "work" but seems a bit hokey.
it does yeah
https://github.com/jkk/honeysql/issues/171 and we can think about / discuss it.
That's nice and clean!
thanks =)