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

Unable to insert a value of type uint64 into the table column of type DECIMAL(20,0). #1985

Open
lakshay2k opened this issue Oct 10, 2023 · 0 comments
Assignees

Comments

@lakshay2k
Copy link

lakshay2k commented Oct 10, 2023

Issue tracker is used for reporting bugs and discussing new features. Please use
Discord or stackoverflow for supporting
issues.

Expected Behavior

When a user try to insert a value of type unit64 (for ex: 9383336886908942973) in the table column of type DECIMAL(20,0). The value in the column should be stored as it is without any wrapping to negative value.

Current Behavior

When a user try to insert a value of type unit64 (for ex: 9383336886908942973) in the table column of type DECIMAL(20,0). The value in the column is stored as negative (for ex: -9063407186800608643).

Possible Solution

The library insert function is converting back the uint64 value to int64 and storing it in the database. Possible solution is to simply map uint64 to uint64 values only, which means only allow signed values

Steps to Reproduce

  1. Create a table with column name flow_id with data type as DECIMAL(20,0).
  2. Create a struct having flow_id attribute of type uint64.
  3. Declare a value of above struct type(assign value as 9383336886908942973) and try to insert in the postgres database using *pg.Db.model().insert() function passing the struct variable.
  4. Check in the database, the record will reflect a negative value which should be -9063407186800608643

Context (Environment)

Any IDE running golang
Connections with database running postgres

Detailed Description

Possible Implementation

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants