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
What just happened to me is that when I do Parse.auto_generate_models!, and try to read a field whose type is Number, I get a value rounded downwards, e.g. 2.8 (Float) becomes 2 (ruby Integer). Furthermore, attempting to set it to Float 2.8, and then saving it, sets the db field to 2. Actually, even just doing set("stuff", 2.8) then get("stuff") returns 2.
Property MyClass#my_field already defined with data type :float. Will be ignored.
when the actual type it's already defined with, is :integer ; generally it reports whatever type I write in the statement, instead of the existing one. See lib/parse/model/core/properties.rb :
if (self.fields[key].present? && BASE_FIELD_MAP[key].nil?) || (self < Parse::Object && BASE_FIELD_MAP.has_key?(key))
warn "Property #{self}##{key} already defined with data type :#{data_type}. Will be ignored."
return false
end
also wrong documentation for def attributes, copy-pasted from def enums :
# @return [Hash] the fields that are marked as enums.
I just created this workaround :
module Parse::Properties::ClassMethods
def remove_property key, **opts
key = key.to_sym
parse_field = opts[:field].to_sym || key.to_s.camelize(:lower)
fields.delete key
fields.delete parse_field
attributes.delete parse_field
remove_method parse_field
remove_method :"#{key}_increment!"
remove_method :"#{key}_decrement!"
end
end
class MyClass
remove_property :my_field, field: :My_Field
property :my_field, :float, field: :My_Field
end
The problem appears when you have a numeric column with float data.
When you get the model, the attribute is formatted as integer instead of float.
The text was updated successfully, but these errors were encountered: