contentful.swift icon indicating copy to clipboard operation
contentful.swift copied to clipboard

Models that conform to Resource and have a member variable named id, breaks resolveLinksArray method

Open neptalire94 opened this issue 3 years ago • 0 comments

  • contentful.swift version number: 5.5.5
  • Xcode version number: 13.4.1
  • Target operating system(s) and version number(s)
    • [x] iOS: 15.5
    • [ ] tvOS:
    • [ ] watchOS:
    • [ ] macOS:
  • Package manager:
    • [ ] Carthage
    • [x] Cocoapods

Hi, I'm reporting this just in case, am not sure if in the docs there's a mention about this, if it is then sorry you can just close this issue.

Models that do conform to EntryDecodable, FieldsKeyQueryable and Resource, if they have id as a member variable it makes an overload of the FlatResource conformance as the id member variable will be overridden, meaning that for instance if you have an array of this class as a member variable of another class, resolveLinksArray will give you an array of NSNull, this is due to the id overload as previously mentioned since:

image

In the for cycle in churnLinks method this linkKey references the sys.id one while:

image

In data cache these entry.id are referencing the id of the model, which in this case if it's overloaded it will not work properly cause the churnLinks method is expecting that the id matches with the sys.id one and will give you an array of NSNulls instead.

neptalire94 avatar Aug 02 '22 15:08 neptalire94