Skip to content

Commit

Permalink
Refactor bson2 package (#4105)
Browse files Browse the repository at this point in the history
  • Loading branch information
AlekSi authored Feb 21, 2024
1 parent 8d9b234 commit 9de2931
Show file tree
Hide file tree
Showing 8 changed files with 780 additions and 701 deletions.
14 changes: 2 additions & 12 deletions internal/bson2/bson2.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,6 @@ package bson2

import (
"fmt"
"math"
"time"

"github.com/cristalhq/bson/bsonproto"
Expand Down Expand Up @@ -99,10 +98,6 @@ const (
// DecodeDeep represents a mode in which nested documents and arrays are decoded recursively;
// RawDocuments and RawArrays are never returned.
decodeDeep

// DecodeCheckOnly represents a mode in which only validity checks are performed (recursively)
// and no decoding happens.
decodeCheckOnly
)

var (
Expand Down Expand Up @@ -144,19 +139,14 @@ type CompositeType interface {
*Document | *Array | RawDocument | RawArray
}

// validBSON checks if v is a valid BSON value (including values of raw types).
func validBSON(v any) error {
// validBSONType checks if v is a valid BSON type (including raw types).
func validBSONType(v any) error {
switch v := v.(type) {
case *Document:
case RawDocument:
case *Array:
case RawArray:

case float64:
if noNaN && math.IsNaN(v) {
return lazyerrors.New("invalid float64 value NaN")
}

case string:
case Binary:
case ObjectID:
Expand Down
Loading

0 comments on commit 9de2931

Please sign in to comment.