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

Bug scanning Numeric in v1.14.1 #211

Closed
kydemy-fran opened this issue Jan 26, 2024 · 3 comments
Closed

Bug scanning Numeric in v1.14.1 #211

kydemy-fran opened this issue Jan 26, 2024 · 3 comments

Comments

@kydemy-fran
Copy link

I have a stored procedure that returns many columns and after the update.
Some of those columns are Numeric (both nullable and not nullable).

Before the update (using 1.14.0 all was good), but after update and release, we have had some complaints from some customers.

I am using:

github.com/jackc/pgtype v1.14.1
github.com/jackc/pgx/v4 v4.18.1

I've created some tests to see what was happening.
I am using the following struct:

type TestData struct {
	AccountID              int      `json:"account_id"`
	Amount                 float64  `json:"amount" kom:"`
	AmountBase             *float64 `json:"amount_base"`
	AmountVat              *float64 `json:"amount_vat"`
}

If I execute the following query directly in PostgreSQL 15.4:

SELECT account_id,amount,amount_base,amount_vat FROM payments.generate_remittances($1,$2);

The result is:

account_id amount amount_base amount_vat
1230 50 50 0
1167 50 50 0
1715 25 25 0
1715 30 30 0

In v.1.14.1 all values for AccountID, AmountBase and AmountVat are correct. But some of the values scanned for Amount are wrong:

AccountID Amount AmountBase AmountVAT
1230 5 50 0
1167 5 50 0
1715 25 25 0
1715 30 30 0

If I roll back to v1.14.0 the values are correct:

AccountID Amount AmountBase AmountVAT
1230 50 50 0
1167 50 50 0
1715 25 25 0
1715 30 30 0

Let me know if you need further details.

I am going to rollback to v1.14.0, but it would be great if someone could take a look into this issue.
Thank you!

@jackc
Copy link
Owner

jackc commented Jan 28, 2024

Let me know if you need further details.

Two things could help.

  1. A test case that someone else could run.
  2. You could bisect between v1.14.0 and v1.14.1. As far as I can tell there are only 2 commits that should have affected numeric support so it should be pretty trivial to determine which is the problem.

@kydemy-fran
Copy link
Author

kydemy-fran commented Jan 30, 2024

I've been trying to do a test without dependencies, and I am not able to replicate.
I am still able to replicate with my project/DB. I am unsure where the problem is.
I'll need to do your second suggestion and debug both versions. Will do sometime later this week.

@kydemy-fran
Copy link
Author

Confirmed, this issue has been resolved in v1.14.2
Thank you!

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

No branches or pull requests

2 participants