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

Uint support #421

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open

Conversation

walnuts1018
Copy link

fix #317

Currently, uint is cast to int64, causing overflow in some values and generating unexpected queries.

Example: (from #317)

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)
}

expect: INSERT INTO tableName (uint_64) VALUES (11169823557460058355)
result: INSERT INTO tableName (uint_64) VALUES (-7276920516249493261)

This PR solves the problem by adding a case for uint.

@walnuts1018
Copy link
Author

@funkyshu Review please.

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.

Does the expression generator really support uint64?
1 participant