databricks / databricks-sql-go

Golang database/sql driver for Databricks SQL.
Apache License 2.0
34 stars 37 forks source link

Error while passing a named parameter with a value of type `*float64` #214

Closed esdrasbeleza closed 2 months ago

esdrasbeleza commented 2 months ago

Summary

If I have a variable typed as *float64 as pass it down to a query as a named parameter, the query won't work because it will be valued as "%!s(float64=3.289113e+06)".

Details

I have the following named parameter:

someFloat := float64(3289113)
namedParam := sql.Named("float64Param", &someFloat)

When inferTypes is called, it's passed down as

Parameter{
  Name: "float64Param",
  Type: SqlUnkown,
  Value: interface{}(float64) 3289113,
}

and the function converts it to

Parameter{
  Name: "float64Param",
  Type: SqlString,
  Value: interface {}(string) "%!s(float64=3.289113e+06)", // wrong!
}

So if I call my query SELECT * FROM table WHERE someField = :float64Param, it won't work because someField won't match "%!s(float64=3.289113e+06)".