Inquery calls str on the values that are passed in when constructing a query. In other words, it assumes .toString is intended to produce a SQL string for a value.
This conflates the string representation of a value with the way the value should be represented in SQL.
As a result, when using inquery, there is a lot of string formatting that needs to occur on the caller side, or else there is a lot of casting values (e.g., uuids).
Even if inquery were extended with different stringification for built in types like UUIDs, there are always other in-built types (e.g., under java.time). And how a particular data type should be turned into a SQL string may vary with the different database being used.
By contrast, libraries like next.jdbc allow you to extend their behavior via protocols to support new data types. For example, if I want to a Clojure map as json or transit, I can simply extend a protocol.
Proposed Solution
Provide a protocol or multimethod that enables the user how to specify the SQL from a value. Use str as a fallback.
Problem
Inquery calls
str
on the values that are passed in when constructing a query. In other words, it assumes.toString
is intended to produce a SQL string for a value.This conflates the string representation of a value with the way the value should be represented in SQL.
As a result, when using inquery, there is a lot of string formatting that needs to occur on the caller side, or else there is a lot of casting values (e.g., uuids).
Even if inquery were extended with different stringification for built in types like UUIDs, there are always other in-built types (e.g., under java.time). And how a particular data type should be turned into a SQL string may vary with the different database being used.
By contrast, libraries like
next.jdbc
allow you to extend their behavior via protocols to support new data types. For example, if I want to a Clojure map as json or transit, I can simply extend a protocol.Proposed Solution
Provide a protocol or multimethod that enables the user how to specify the SQL from a value. Use
str
as a fallback.