I was wondering, is there a way to make sql/format
output non prepared statements?
it's just useful for debugging sometimes to use non prepared statements, but looking at the code I don't see a way to do that now
is there another way to transform prepared SQL statements into "regular" SQL statements?
HoneySQL does not produce "prepared statements", it just produces data.
uhm I mean something like
(sql/format (load-players-sql 100))
["SELECT * FROM player pl INNER JOIN league_players lg ON pl.id = lg.player_id WHERE lg.league_id = ?"
100]
isn't that a prepared statement?
That's just data.
Libraries like clojure.java.jdbc
and next.jdbc
create PreparedStatement
s.
You can use (types/inline 100)
(where types
is honeysql.types
) to tell HoneySQL to inline the value -- but bear in mind it does not know how to convert Clojure data to SQL values (that's up to the JDBC driver) so inline
is a pure textual substitution, so you need to take care of quoting SQL strings etc.
HoneySQL just converts Clojure data structures into a vector containing a SQL query/command string and pulls all the "loose" Clojure data values out into that vector. clojure.java.jdbc
and next.jdbc
create prepared statements from that SQL string and add in the values as parameters, but it is the JDBC driver that does all of the conversion.