Skip to content

Commit 713f050

Browse files
committed
fix int values for extract week
1 parent ae3a154 commit 713f050

File tree

1 file changed

+7
-6
lines changed

1 file changed

+7
-6
lines changed

sql/expression/function/extract.go

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -136,22 +136,23 @@ func (td *Extract) Eval(ctx *sql.Context, row sql.Row) (interface{}, error) {
136136
if err != nil {
137137
return nil, err
138138
}
139-
yyyy, ok := year(date).(int32)
139+
yyyy, ok := year(date).(int)
140140
if !ok {
141141
return nil, sql.ErrInvalidArgumentDetails.New("WEEK", "invalid year")
142142
}
143-
mm, ok := month(date).(int32)
143+
mm, ok := month(date).(int)
144144
if !ok {
145145
return nil, sql.ErrInvalidArgumentDetails.New("WEEK", "invalid month")
146146
}
147-
dd, ok := day(date).(int32)
147+
dd, ok := day(date).(int)
148148
if !ok {
149149
return nil, sql.ErrInvalidArgumentDetails.New("WEEK", "invalid day")
150150
}
151-
yearForWeek, week := calcWeek(yyyy, mm, dd, weekBehaviourYear)
152-
if yearForWeek < yyyy {
151+
yr := int32(yyyy)
152+
yearForWeek, week := calcWeek(yr, int32(mm), int32(dd), weekBehaviourYear)
153+
if yearForWeek < yr {
153154
week = 0
154-
} else if yearForWeek > yyyy {
155+
} else if yearForWeek > yr {
155156
week = 53
156157
}
157158
return int(week), nil

0 commit comments

Comments
 (0)