@@ -51,7 +51,7 @@ import {
51
51
MapValue as ProtoMapValue ,
52
52
Value as ProtoValue
53
53
} from '../protos/firestore_proto_api' ;
54
- import { toNumber } from '../remote/number_serializer' ;
54
+ import { toDouble , toNumber } from '../remote/number_serializer' ;
55
55
import {
56
56
JsonProtoSerializer ,
57
57
toBytes ,
@@ -908,7 +908,7 @@ function parseScalarValue(
908
908
)
909
909
} ;
910
910
} else if ( value instanceof VectorValue ) {
911
- return parseVectorValue ( value ) ;
911
+ return parseVectorValue ( value , context ) ;
912
912
} else {
913
913
throw context . createError (
914
914
`Unsupported field value: ${ valueDescription ( value ) } `
@@ -919,7 +919,10 @@ function parseScalarValue(
919
919
/**
920
920
* Creates a new VectorValue proto value (using the internal format).
921
921
*/
922
- export function parseVectorValue ( value : VectorValue ) : ProtoValue {
922
+ export function parseVectorValue (
923
+ value : VectorValue ,
924
+ context : ParseContextImpl
925
+ ) : ProtoValue {
923
926
const mapValue : ProtoMapValue = {
924
927
fields : {
925
928
[ TYPE_KEY ] : {
@@ -928,9 +931,13 @@ export function parseVectorValue(value: VectorValue): ProtoValue {
928
931
[ VECTOR_MAP_VECTORS_KEY ] : {
929
932
arrayValue : {
930
933
values : value . toArray ( ) . map ( value => {
931
- return {
932
- doubleValue : value
933
- } ;
934
+ if ( typeof value !== 'number' ) {
935
+ throw context . createError (
936
+ 'VectorValues must only contain numeric values.'
937
+ ) ;
938
+ }
939
+
940
+ return toDouble ( context . serializer , value ) ;
934
941
} )
935
942
}
936
943
}
0 commit comments