Skip to content

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

Closed

Description

@esdrasbeleza

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)".

Activity

  1. added a commit that references this issue on Apr 12, 2024
    7c4ada8
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions