-
Notifications
You must be signed in to change notification settings - Fork 21
Description
Description
Across many models with "additionalAttributes", the equality check effectively only checks if additionalAttributes is equal. See lines 273 and 274 below.
datadog-api-client-ruby/lib/datadog_api_client/v2/models/service_definition_v2_dot2.rb
Lines 256 to 275 in 130eb02
| def ==(o) | |
| return true if self.equal?(o) | |
| self.class == o.class && | |
| application == o.application && | |
| ci_pipeline_fingerprints == o.ci_pipeline_fingerprints && | |
| contacts == o.contacts && | |
| dd_service == o.dd_service && | |
| description == o.description && | |
| extensions == o.extensions && | |
| integrations == o.integrations && | |
| languages == o.languages && | |
| lifecycle == o.lifecycle && | |
| links == o.links && | |
| schema_version == o.schema_version && | |
| tags == o.tags && | |
| team == o.team && | |
| tier == o.tier && | |
| type == o.type | |
| additional_properties == o.additional_properties | |
| end |
Since this is so widespread, it seems like an issue with code generation. When regenerated with the fix to this issue, the individual code might change like so:
tier == o.tier &&
- type == o.type
+ type == o.type &&
additional_properties == o.additional_propertiesTo Reproduce
Initialize any two different models that can have additionalAttributes and run an equality comparison:
> DatadogAPIClient::V2::ServiceDefinitionV2Dot2.new == DatadogAPIClient::V2::ServiceDefinitionV1.new
=> trueOr initialize the same model but with different properties and run an equality comparison:
> DatadogAPIClient::V2::ServiceDefinitionV2Dot2.new(dd_service: "serviceA") == DatadogAPIClient::V2::ServiceDefinitionV2Dot2.new(dd_service: "serviceB")
=> trueExpected behavior
- No two objects of different classes ought to be equivalent.
- When comparing instances of the same classes with different model property values, they should not be equivalent.
Environment and Versions:
A clear and precise description of your setup:
- Ruby 3.2.6
- DatadogAPIClient 2.28.1
- Also present in
master.