You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
# @param [ Symbol | Class ] type The type of the field.
793
+
# @param [ Symbol ] field_name The name of the field.
794
+
# @param [ Symbol | Class ] raw_type The type of the field.
812
795
#
813
796
# @return [ Class ] The type of the field.
814
797
#
815
-
# @raises [ Mongoid::Errors::InvalidFieldType ] if given an invalid field
798
+
# @raises [ Mongoid::Errors::UnknownFieldType ] if given an invalid field
816
799
# type.
817
800
#
818
801
# @api private
819
-
defretrieve_and_validate_type(name,type)
820
-
type_mapping=TYPE_MAPPINGS[type]
821
-
result=type_mapping || unmapped_type(type)
822
-
if !result.is_a?(Class)
823
-
raiseErrors::InvalidFieldType.new(self,name,type)
824
-
else
825
-
ifINVALID_BSON_CLASSES.include?(result)
826
-
warn_message="Using #{result} as the field type is not supported. "
827
-
ifresult == BSON::Decimal128
828
-
warn_message += "In BSON <= 4, the BSON::Decimal128 type will work as expected for both storing and querying, but will return a BigDecimal on query in BSON 5+."
829
-
else
830
-
warn_message += "Saving values of this type to the database will work as expected, however, querying them will return a value of the native Ruby Integer type."
# Returns the type of the field if the type was not in the TYPE_MAPPINGS
839
-
# hash.
809
+
# Logs a warning message if the given type cannot be represented
810
+
# by BSON.
840
811
#
841
-
# @param [ Symbol | Class ] type The type of the field.
842
-
#
843
-
# @return [ Class ] The type of the field.
812
+
# @param [ Class ] type The type of the field.
844
813
#
845
814
# @api private
846
-
defunmapped_type(type)
847
-
if"Boolean" == type.to_s
848
-
Mongoid::Boolean
815
+
defwarn_if_unsupported_bson_type(type)
816
+
returnunlessUNSUPPORTED_BSON_TYPES.include?(type)
817
+
warn_message="Using #{type} as the field type is not supported. "
818
+
iftype == BSON::Decimal128
819
+
warn_message += "In BSON <= 4, the BSON::Decimal128 type will work as expected for both storing and querying, but will return a BigDecimal on query in BSON 5+."
849
820
else
850
-
type|| Object
821
+
warn_message += "Saving values of this type to the database will work as expected, however, querying them will return a value of the native Ruby Integer type."
0 commit comments