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

[Bug]: Frozen object has incorrect property indices #2670

Closed
nirinchev opened this issue Oct 4, 2021 · 5 comments
Closed

[Bug]: Frozen object has incorrect property indices #2670

nirinchev opened this issue Oct 4, 2021 · 5 comments
Assignees

Comments

@nirinchev
Copy link
Member

Reported on the forums: https://www.mongodb.com/community/forums/t/realm-sync-net-freezing-an-object-on-a-synced-realm-messes-the-properties-up/126797

Looks like we're somehow using an incorrect object schema when looking up the properties, but it's not obvious what's causing it.

@nirinchev nirinchev self-assigned this Oct 4, 2021
@JamieColclough
Copy link

I couldn't attach the zip so here's a link to the project that has it. https://github.com/JamieColclough/Frozen-object-has-incorrect-property-indices/tree/main/RealmSyncFreezeError I couldn't upload the packages but hopefully you can build the project with this

@papafe papafe self-assigned this Oct 5, 2021
@papafe
Copy link
Contributor

papafe commented Oct 6, 2021

@JamieColclough thanks a lot for your project! We managed to reproduce the issue and we're currently investigating it.

@JamieColclough
Copy link

@papafe Thanks! in the meantime, is there a workaround I can do so I can still use the frozen realm?

@papafe
Copy link
Contributor

papafe commented Oct 6, 2021

@JamieColclough we found the cause of the issue and we are working on a fix.
The workaround for now would be to have exactly the same schema locally as you have on MongoDB Realm (including the partition key). For example, ClinicAppointment would look like this:

    [MapTo("clinic_appointment")]
    public class ClinicAppointment : RealmObject
    {
        [PrimaryKey]
        [MapTo("_id")]
        public int AppointmentId { get; set; }

        [MapTo("_partition")]
        [Required]
        public string Partition { get; set; } //This is what you are missing right now

        [MapTo("appointment_time")]
        public DateTimeOffset AppointmentTime { get; set; }

        [MapTo("clinic_schedule_id")]
        public ClinicSchedule ClinicSchedule { get; set; }

        [MapTo("clinician_id")]
        public Clinician Clinician { get; set; }

        [MapTo("is_uploading")]
        public bool IsUploading { get; set; }

        [MapTo("patient_record")]
        public PatientRecord PatientRecord { get; set; }

        [MapTo("patient_seen")]
        public bool PatientSeen { get; set; }

        [MapTo("status_id")]
        public int StatusId { get; set; }
    }

I don't know how exactly you are using frozen objects, as I suppose the project that you shared is probably a very simplified version of your use case, but I could also suggest not freezing the realm for now and just use the live objects.

@sync-by-unito sync-by-unito bot assigned nirinchev and unassigned papafe Nov 23, 2021
@nirinchev
Copy link
Member Author

This was fixed in 10.7.1.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Mar 15, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants