Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

lua/pg: Use fmt for formatting number query parameters #4

Merged
merged 1 commit into from
Nov 7, 2024

Conversation

pfirsich
Copy link
Collaborator

@pfirsich pfirsich commented Nov 7, 2024

snprintf will format floating point numbers using scientific notation, even if they are representing integers exactly, so when passing a number as a query parameter, postgres would get e.g. "1e+4" and it would complain about this being an invalid parameter for a column of integer type. fmt does the correct thing here and it will format floats representing integers precisely as integers (without period or exponent).

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature.
snprintf will format floating point numbers using scientific notation,
even if they are representing integers exactly, so when passing a number
as a query parameter, postgres would get e.g. "1e+4" and it would
complain about this being an invalid parameter for a column of integer
type. fmt does the correct thing here and it will format floats
representing integers precisely as integers (without period or
exponent).
@MaxKellermann MaxKellermann merged commit 69423b1 into CM4all:master Nov 7, 2024
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants