Skip to content

Uint support#421

Open
walnuts1018 wants to merge 1 commit into
doug-martin:masterfrom
walnuts1018:uint-support
Open

Uint support#421
walnuts1018 wants to merge 1 commit into
doug-martin:masterfrom
walnuts1018:uint-support

Conversation

@walnuts1018

Copy link
Copy Markdown

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
Copy Markdown
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