Fork me on GitHub
#sql
<
2016-07-14
>
scott-abernethy04:07:41

With HugSQL, how do you deal with nullable parameters in inserts/updates? Setting the parameter as nil results in Parameter Mismatch: :foo parameter data not found.

curtis.summers12:07:58

@scott-abernethy: Are you using the latest HugSQL 0.4.7? There was a bug a while back that would error on false or nil values, but that was fixed. HugSQL does expect the parameter keyword to exist, though, so you need to pass nil in as the parameter value. If you want to omit the parameter entirely, then look at Clojure Expressions to conditionally introduce parameters into your query at runtime: http://www.hugsql.org/#using-expressions

scott-abernethy21:07:35

@curtis.summers: Yes, upgrading fixed the issue. Thanks!