Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(spanner): add support of float32 type #9525

Merged
merged 3 commits into from
Mar 8, 2024
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
Prev Previous commit
incorporate suggestions
  • Loading branch information
rahul2393 committed Mar 8, 2024
commit 12bed253d4537835d5e3559446c3d392d5176903
10 changes: 5 additions & 5 deletions spanner/value.go
Original file line number Diff line number Diff line change
Expand Up @@ -429,24 +429,24 @@ func (n NullFloat64) GormDataType() string {

// NullFloat32 represents a Cloud Spanner FLOAT32 that may be NULL.
type NullFloat32 struct {
Float32 float32 // Float64 contains the value when it is non-NULL, and zero when NULL.
Float32 float32 // Float32 contains the value when it is non-NULL, and zero when NULL.
Valid bool // Valid is true if FLOAT32 is not NULL.
}

// IsNull implements NullableValue.IsNull for NullFloat64.
// IsNull implements NullableValue.IsNull for NullFloat32.
func (n NullFloat32) IsNull() bool {
return !n.Valid
}

// String implements Stringer.String for NullFloat64
// String implements Stringer.String for NullFloat32
func (n NullFloat32) String() string {
if !n.Valid {
return nullString
}
return fmt.Sprintf("%v", n.Float32)
}

// MarshalJSON implements json.Marshaler.MarshalJSON for NullFloat64.
// MarshalJSON implements json.Marshaler.MarshalJSON for NullFloat32.
func (n NullFloat32) MarshalJSON() ([]byte, error) {
return nulljson(n.Valid, n.Float32)
}
Expand Down Expand Up @@ -2945,7 +2945,7 @@ func errUnexpectedFloat32Str(s string) error {
return spannerErrorf(codes.FailedPrecondition, "unexpected string value %q for float32 number", s)
}

// getFloat64Value returns the float32 value encoded in proto3.Value v whose
// getFloat32Value returns the float32 value encoded in proto3.Value v whose
// kind is proto3.Value_NumberValue / proto3.Value_StringValue.
// Cloud Spanner uses string to encode NaN, Infinity and -Infinity.
func getFloat32Value(v *proto3.Value) (float32, error) {
Expand Down