Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

generated isEquals fails when a repeated object has no entries #35

Open
honus opened this issue Mar 5, 2013 · 0 comments
Open

generated isEquals fails when a repeated object has no entries #35

honus opened this issue Mar 5, 2013 · 0 comments

Comments

@honus
Copy link

honus commented Mar 5, 2013

We have an object which includes a repeated field called errors.
Here is the return from the generated isEquals method:

  return
      self.hasType == otherMessage.hasType &&
      (!self.hasType || self.type == otherMessage.type) &&
      self.hasStatus == otherMessage.hasStatus &&
      (!self.hasStatus || self.status == otherMessage.status) &&
      self.hasMessage == otherMessage.hasMessage &&
      (!self.hasMessage || [self.message isEqual:otherMessage.message]) &&
      [self.errorsArray isEqualToArray:otherMessage.errorsArray] &&
      [self isEqualExtensionsInOther:otherMessage from:100 to:536870912] &&
      (self.unknownFields == otherMessage.unknownFields || (self.unknownFields != nil && [self.unknownFields isEqual:otherMessage.unknownFields]));

In my case errorsArray is nil. I am assuming this is because there were no errors (since zero is a valid number of times for a repeated field). This makes [self.errorsArray isEqualToArray:otherMessage.errorsArray] returns false. The end result is objects with repeated fields that have zero entries can never test equal.

I can imagine a couple of fixes, e.g. having an empty array instead of nil or changing the test to make both sides being nil a valid situation, however I am not familiar enough with the code to know exactly where to place this. I glanced at the code that generates isEqualToArray but I'm not sure if the adding the nil test is always valid.

Packetdancer pushed a commit to Packetdancer/protobuf-objc that referenced this issue Feb 23, 2015
Some minor improvements to README
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant