* Given a bson type returns the lowest value for that type bracket * for the sort order type. */
| 4077 | * for the sort order type. |
| 4078 | */ |
| 4079 | static bson_value_t |
| 4080 | GetLowerBoundForLessThan(bson_type_t inputBsonType) |
| 4081 | { |
| 4082 | bson_value_t minValue = { 0 }; |
| 4083 | minValue.value_type = BSON_TYPE_MINKEY; |
| 4084 | switch (inputBsonType) |
| 4085 | { |
| 4086 | case BSON_TYPE_EOD: |
| 4087 | case BSON_TYPE_MINKEY: |
| 4088 | { |
| 4089 | /* The minValue for MinKey is MinKey */ |
| 4090 | return minValue; |
| 4091 | } |
| 4092 | |
| 4093 | case BSON_TYPE_UNDEFINED: |
| 4094 | case BSON_TYPE_NULL: |
| 4095 | { |
| 4096 | /* Use MinKey here since null has custom semantics */ |
| 4097 | return minValue; |
| 4098 | } |
| 4099 | |
| 4100 | case BSON_TYPE_DOUBLE: |
| 4101 | case BSON_TYPE_INT32: |
| 4102 | case BSON_TYPE_INT64: |
| 4103 | case BSON_TYPE_DECIMAL128: |
| 4104 | { |
| 4105 | minValue.value_type = BSON_TYPE_DOUBLE; |
| 4106 | minValue.value.v_double = NAN; |
| 4107 | return minValue; |
| 4108 | } |
| 4109 | |
| 4110 | case BSON_TYPE_UTF8: |
| 4111 | case BSON_TYPE_SYMBOL: |
| 4112 | { |
| 4113 | minValue.value_type = inputBsonType; |
| 4114 | minValue.value.v_utf8.len = 0; |
| 4115 | minValue.value.v_utf8.str = ""; |
| 4116 | return minValue; |
| 4117 | } |
| 4118 | |
| 4119 | case BSON_TYPE_DOCUMENT: |
| 4120 | { |
| 4121 | /* Return an empty document */ |
| 4122 | pgbson *bson = PgbsonInitEmpty(); |
| 4123 | return ConvertPgbsonToBsonValue(bson); |
| 4124 | } |
| 4125 | |
| 4126 | case BSON_TYPE_ARRAY: |
| 4127 | { |
| 4128 | pgbson_writer bsonWriter; |
| 4129 | |
| 4130 | /* now create a bson for that path which has the min value for the field */ |
| 4131 | /* we map this to an empty array since that's the smallest value we'll encounter */ |
| 4132 | PgbsonWriterInit(&bsonWriter); |
| 4133 | PgbsonWriterAppendEmptyArray(&bsonWriter, "", 0); |
| 4134 | pgbson *doc = PgbsonWriterGetPgbson(&bsonWriter); |
| 4135 | |
| 4136 | pgbsonelement termElement; |
no test coverage detected