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

Does the expression generator really support uint64? #317

Open
Hackfred opened this issue Dec 14, 2021 · 0 comments · May be fixed by #421
Open

Does the expression generator really support uint64? #317

Hackfred opened this issue Dec 14, 2021 · 0 comments · May be fixed by #421

Comments

@Hackfred
Copy link

Hackfred commented Dec 14, 2021

This lib can build Insert queries from a struct which is a very nice and handy feature. I might get something wrong here, but this seems not to work for uint64 fields, as they are casted at some point to int64 values which lets some uint64 values overflow. See the following example:

package main

import (
	"github.com/doug-martin/goqu/v9"
	_ "github.com/doug-martin/goqu/v9/dialect/mysql" // needed for mysql dialect of query builder
)

type Sample struct {
	Uint64 uint64 `db:"uint_64"`
}

func main() {
	sample := Sample{
		Uint64: 11169823557460058355,
	}
	dialect := goqu.Dialect("mysql")
	query := dialect.Insert("tableName").Rows(sample)
	sql, _, _:= query.ToSQL()
	print(sql)
}

This will create the following query: INSERT INTO tableName (uint_64) VALUES (-7276920516249493261)
What I would expect is this query: INSERT INTO tableName (uint_64) VALUES (11169823557460058355)

Am I using this lib in a wrong way or is this an error inside the lib?

XIELongDragon added a commit to XIELongDragon/goqu that referenced this issue Dec 19, 2021
This was referenced Dec 19, 2021
XIELongDragon added a commit to XIELongDragon/goqu that referenced this issue Dec 19, 2021
XIELongDragon added a commit to XIELongDragon/goqu that referenced this issue Dec 19, 2021
XIELongDragon added a commit to XIELongDragon/goqu that referenced this issue Dec 20, 2021
XIELongDragon added a commit to XIELongDragon/goqu that referenced this issue Dec 20, 2021
CCS-CloudServices added a commit to CCS-CloudServices/goqu that referenced this issue Dec 20, 2021
uint64 cast to int64 caused lost of data doug-martin#317
XIELongDragon added a commit to XIELongDragon/goqu that referenced this issue Feb 13, 2022
uint64 cast to int64 caused lost of data doug-martin#317
@walnuts1018 walnuts1018 linked a pull request May 20, 2024 that will close this issue
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 a pull request may close this issue.

1 participant