44 "fmt"
55 "github.com/viant/parsly"
66 "github.com/viant/sqlparser/schema"
7+ "math"
78 "strings"
89)
910
@@ -71,11 +72,17 @@ func parseRegisterSet(cursor *parsly.Cursor, destination *schema.RegisterSet) er
7172 return cursor .NewError (setKeywordMatcher )
7273 }
7374
74- ttl64 , err := match .Int (cursor )
75+ ttl64 , err := match .Uint (cursor )
7576 if err != nil {
7677 return fmt .Errorf ("parseregisterset unable to get int value due to: %w" , err )
7778 }
78- destination .TTL = int (ttl64 )
79+
80+ ttlUint32 , err := uint64ToUint32 (ttl64 )
81+ if err != nil {
82+ return fmt .Errorf ("parseregisterset unable to get uint32 value due to: %w" , err )
83+ }
84+
85+ destination .TTL = ttlUint32
7986 }
8087
8188 match = cursor .MatchAfterOptional (whitespaceMatcher , selectorMatcher )
@@ -90,3 +97,14 @@ func parseRegisterSet(cursor *parsly.Cursor, destination *schema.RegisterSet) er
9097 destination .Spec = strings .TrimSpace (string (cursor .Input [cursor .Pos :]))
9198 return nil
9299}
100+
101+ func uint64ToUint32 (value uint64 ) (uint32 , error ) {
102+ if value > math .MaxUint32 {
103+ return 0 , fmt .Errorf ("value %d is out of range for uint32, max value accepted: %d" , value , math .MaxUint32 )
104+ }
105+
106+ if value < 0 {
107+ return 0 , fmt .Errorf ("value %d is out of range for uint32, min value accepted: %d" , value , 0 )
108+ }
109+ return uint32 (value ), nil
110+ }
0 commit comments