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
However, it does not accept a string for integer fields, even though strings respond to to_i:
2.2.0 > a = Account.new
=> #<Account balance=0.0 transactions_count=0 balance_updated_at=0
2.2.0 > a.transactions_count = "1"
TypeError: Unacceptable value 1 for field transactions_count of type Protobuf::Field::Int64Field
Curiously, it will accept a time for integer fields, but does not convert it to an integer, even though it does so with strings on double fields:
2.2.0 > a = Account.new
=> #<Account balance=0.0 transactions_count=0 balance_updated_at=0
2.2.0 > a.balance_updated_at = Time.current
=> Tue, 24 Feb 2015 20:09:08 UTC +00:00
This, of course, becomes a problem once it attempts to encode the message:
2.2.0 > a = Account.new(:balance_updated_at => Time.current)
=> #<Account balance=0.0 transactions_count=0 balance_updated_at=Tue, 24 Feb 2015 20:09:08 UTC +00:00
2.2.0 > a.encode
NoMethodError: undefined method `&' for Tue, 24 Feb 2015 21:17:58 UTC +00:00:Time
...
There may actually be two issues here, but I wanted to document the inconsistent behavior so we can start discussion a possible solution. If we need to split this into two, I'm happy to do so.
The text was updated successfully, but these errors were encountered:
- should standardize how we coerced Integer/Float values in pb
- need to coerce value in Varint to make sure it is in bounds
- bounds should be inclusive
I'm seeing some inconsistencies in how we handle field serialization for different field types, which seems wrong.
Given the following definition:
Protobuf gladly accepts a string for double fields, presumably because strings respond to
to_f
:However, it does not accept a string for integer fields, even though strings respond to
to_i
:Curiously, it will accept a time for integer fields, but does not convert it to an integer, even though it does so with strings on double fields:
This, of course, becomes a problem once it attempts to encode the message:
There may actually be two issues here, but I wanted to document the inconsistent behavior so we can start discussion a possible solution. If we need to split this into two, I'm happy to do so.
The text was updated successfully, but these errors were encountered: