Skip to content

Commit

Permalink
Fixes couchbaselabs#84: Output NullValue to non-zero numeric values
Browse files Browse the repository at this point in the history
  • Loading branch information
nelio2k committed Jan 24, 2019
1 parent a347884 commit 5f91646
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion fastval.go
Original file line number Diff line number Diff line change
Expand Up @@ -187,6 +187,8 @@ func (val FastVal) AsInt() int64 {
return 1
case FalseValue:
return 0
case NullValue:
return math.MinInt64
}
return 0
}
Expand All @@ -212,6 +214,8 @@ func (val FastVal) AsUint() uint64 {
return 1
case FalseValue:
return 0
case NullValue:
return math.MaxUint64
}
return 0
}
Expand All @@ -237,12 +241,14 @@ func (val FastVal) AsFloat() float64 {
return 1.0
case FalseValue:
return 0.0
case NullValue:
return math.MaxFloat64
}
return 0.0
}

func (val FastVal) AsBoolean() bool {
return val.AsInt() != 0
return val.AsInt() != 0 && val.AsInt() != math.MinInt64
}

func (val FastVal) AsRegex() FastValRegexIface {
Expand Down

0 comments on commit 5f91646

Please sign in to comment.