3
0

Fix RecordValue dateOnly and timeOnly casting

and Gval nil DateTime value
This commit is contained in:
Mumbi Francis
2024-10-23 16:21:57 +03:00
committed by Mumbi Francis
parent 0bf54d0ce4
commit 031374e88b
2 changed files with 19 additions and 0 deletions

View File

@@ -293,6 +293,11 @@ func composeRecordValuesGValSelector(res *types.Record, k string) (interface{},
return false, nil
}
// return nil time.Time for date and time fields
if field != nil && (field.IsDateOnly() || field.IsDateTime() || field.IsTimeOnly()) {
return expr.NewDateTime(nil)
}
return nil, nil
case len(vv) == 1 && !multiValueField:

View File

@@ -79,6 +79,20 @@ func (v RecordValue) Cast(f *ModuleField) (interface{}, error) {
}
return cast.ToTimeE(v.Value)
case f.IsDateOnly():
if v.Value == "" {
return nil, nil
}
return time.Parse(DateOnlyLayout, v.Value)
case f.IsTimeOnly():
if v.Value == "" {
return nil, nil
}
return time.Parse(TimeOnlyLayout, v.Value)
case f.IsBoolean():
return expr.CastToBoolean(v.Value)