MCPcopy Create free account
hub / github.com/documentdb/documentdb / BsonValueAsBool

Function BsonValueAsBool

pg_documentdb_core/src/query/bson_compare.c:709–752  ·  view source on GitHub ↗

* Converts a bson value to bool * It returns true for any Numeric value not 0 and false for any 0. * For non Numeric, it returns false for EOD, Undefined or NULL and true for any other value. */

Source from the content-addressed store, hash-verified

707 * For non Numeric, it returns false for EOD, Undefined or NULL and true for any other value.
708 */
709bool
710BsonValueAsBool(const bson_value_t *value)
711{
712 switch (value->value_type)
713 {
714 case BSON_TYPE_BOOL:
715 {
716 return value->value.v_bool;
717 }
718
719 case BSON_TYPE_DOUBLE:
720 {
721 return value->value.v_double != 0.0;
722 }
723
724 case BSON_TYPE_INT32:
725 {
726 return value->value.v_int32 != 0;
727 }
728
729 case BSON_TYPE_INT64:
730 {
731 return value->value.v_int64 != 0;
732 }
733
734 case BSON_TYPE_DECIMAL128:
735 {
736 return !IsDecimal128Zero(value);
737 }
738
739 case BSON_TYPE_NULL:
740 case BSON_TYPE_EOD:
741 case BSON_TYPE_UNDEFINED:
742 {
743 return false;
744 }
745
746 default:
747 {
748 /* Any other value evaluates to true. */
749 return true;
750 }
751 }
752}
753
754
755/* Given a bson value it tries to get its date time representation in milliseconds. */

Callers 15

command_list_databasesFunction · 0.85
command_validateFunction · 0.85
PopulateCurrentOpOptionsFunction · 0.85
ParseCreateSpecFunction · 0.85
ParseCreateIndexesArgFunction · 0.85
command_coll_modFunction · 0.85
ParseDollarCondFunction · 0.85

Calls 1

IsDecimal128ZeroFunction · 0.85

Tested by

no test coverage detected