Skip to content

Creating an object with properties that are new objects which consist of the exact same properties as other new objects causes schema error #151

@jaysonng

Description

@jaysonng

New Issue Checklist

Issue Description

saving an object with pointers and pointers point to objects with the same struct causes schema error when saving.

caught error: "ParseError code=111 error=schema mismatch for TestObject.test1; expected Pointer<Test1> but got Pointer<Test3>"

Parse-Swift in the middle of saving the pointers gets confused as to what the object is.

Steps to reproduce

Given something like so:

    struct Test1: ParseObject {
        //: Those are required for Object
        var originalData: Data?
        var objectId: String?
        var createdAt: Date?
        var updatedAt: Date?
        var ACL: ParseACL?

        var description: String?
    }
    
    struct Test2: ParseObject {
        //: Those are required for Object
        var originalData: Data?
        var objectId: String?
        var createdAt: Date?
        var updatedAt: Date?
        var ACL: ParseACL?

        var name: String?
    }
    
    struct Test3: ParseObject {
        //: Those are required for Object
        var originalData: Data?
        var objectId: String?
        var createdAt: Date?
        var updatedAt: Date?
        var ACL: ParseACL?

        var type: String?
    }

    struct TestObject: ParseObject {
        //: Those are required for Object
        var originalData: Data?
        var objectId: String?
        var createdAt: Date?
        var updatedAt: Date?
        var ACL: ParseACL?

        var test1: Test1?
        var test2: Test2?
        var test3: Test3?
    }

    func testSaving() async throws {
        var acl = ParseACL()
        acl.publicRead = true
        acl.publicWrite = false

        var testObject = TestObject()
        testObject.test1 = Test1(ACL: acl)
        testObject.test2 = Test2(ACL: acl)
        testObject.test3 = Test3(ACL: acl)

        do {
            try await testObject.save()
        } catch {
            throw error
        }
    }

running testSaving() will cause the schema error.

Even if there's only 2 that are the same - will cause an error.

        var testObject = TestObject()
        testObject.test1 = Test1(ACL: acl, description: "test1")
        testObject.test2 = Test2(ACL: acl)
        testObject.test3 = Test3(ACL: acl)

However, adding extra arguments to differentiate each object clearly like so:

 func testSaving() async throws {
        var acl = ParseACL()
        acl.publicRead = true
        acl.publicWrite = false

        var testObject = TestObject()
        testObject.test1 = Test1(ACL: acl, description: "test1")
        testObject.test2 = Test2(ACL: acl, name: "test2")
        testObject.test3 = Test3(ACL: acl, type: "test3")

        do {
            try await testObject.save()
        } catch {
            throw error
        }
    }

will save the testObject successfully.

Actual Outcome

schema error

caught error: "ParseError code=111 error=schema mismatch for TestObject.test1; expected Pointer<Test1> but got Pointer<Test3>"

Expected Outcome

object should still save successfully.

Environment

Client

  • Parse Swift SDK version: 5.8.3
  • Xcode version: 15.2
  • Operating system (iOS, macOS, watchOS, etc.): MacOS
  • Operating system version: 17.1.1

Server

  • Parse Server version: 6.4
  • Operating system: MacOS
  • Local or remote host (AWS, Azure, Google Cloud, Heroku, Digital Ocean, etc): local

Database

  • System (MongoDB or Postgres): mongodb
  • Database version: 6
  • Local or remote host (MongoDB Atlas, mLab, AWS, Azure, Google Cloud, etc): local

Logs

Metadata

Metadata

Assignees

No one assigned

    Labels

    wontfixThis will not be worked on

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions