Skip to content

Commit

Permalink
Merge pull request #824 from duglin/issue820
Browse files Browse the repository at this point in the history
Avoid int parsing overflow issues
  • Loading branch information
lionelvillard committed Dec 8, 2022
2 parents f0c10d8 + a85b4de commit 2298be0
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 2 deletions.
2 changes: 1 addition & 1 deletion sql/v2/parser/expression_visitor.go
Original file line number Diff line number Diff line change
Expand Up @@ -277,7 +277,7 @@ func (v *expressionVisitor) VisitStringLiteral(ctx *gen.StringLiteralContext) in
}

func (v *expressionVisitor) VisitIntegerLiteral(ctx *gen.IntegerLiteralContext) interface{} {
val, err := strconv.Atoi(ctx.GetText())
val, err := strconv.ParseInt(ctx.GetText(), 10, 32)
if err != nil {
v.parsingErrors = append(v.parsingErrors, err)
}
Expand Down
2 changes: 1 addition & 1 deletion sql/v2/utils/casting.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ func Cast(val interface{}, target cesql.Type) (interface{}, error) {
case cesql.IntegerType:
switch val.(type) {
case string:
v, err := strconv.Atoi(val.(string))
v, err := strconv.ParseInt(val.(string), 10, 32)
if err != nil {
err = fmt.Errorf("cannot cast from String to Integer: %w", err)
}
Expand Down

0 comments on commit 2298be0

Please sign in to comment.