doug-martin / goqu

SQL builder and query library for golang
http://doug-martin.github.io/goqu/
MIT License
2.36k stars 205 forks source link

Handling trailing zeros #331

Open kilianstallz opened 2 years ago

kilianstallz commented 2 years ago

Describe the bug For some of our calculations, we must store the correct amount of trailing zeros to a float-value.

Is there a way to preserve trailing-zeros on float values?

Expected behavior got: UPDATE "users" SET "Age"=2.5 WHERE (("Id" = 1) AND ("Name" = 'John') AND ("Age" = 2.5)) expected: UPDATE "users" SET "Age"=2.5000 WHERE (("Id" = 1) AND ("Name" = 'John') AND ("Age" = 2.5000))

Dialect:

akarl commented 2 years ago

I'm not going to ask why you would need that.

Floating point numbers in Go doesn't actually have trailing zeros because that isn't stored anywhere. You can read more about how it works here https://en.wikipedia.org/wiki/IEEE_754.

What have you tried so far?