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

RealmList is not saved as part of model #334

Closed
tarasmorskyi-mediamonks opened this issue Jul 2, 2021 · 4 comments · Fixed by #338
Closed

RealmList is not saved as part of model #334

tarasmorskyi-mediamonks opened this issue Jul 2, 2021 · 4 comments · Fixed by #338
Assignees

Comments

@tarasmorskyi-mediamonks
Copy link

tarasmorskyi-mediamonks commented Jul 2, 2021

If I have a model with RealmList in it the list is not getting copied into realm as any other field does. Example of used model:
class SampleEntity : RealmObject {
@PrimaryKey
var productId: String = ""
var price: Double = 0.0
var children: RealmList = RealmList()
}

@cmelchior
Copy link
Contributor

Thanks @tarasmorskyi-mediamonks

Exactlly what do you mean by being copied into Realm? Do you have a full example you can post?

@tarasmorskyi-mediamonks
Copy link
Author

unfortunately I cannot share the real peace of code but this will represent the idea:
Screenshot 2021-07-02 at 14 47 21
Screenshot 2021-07-02 at 14 49 01

@nhachicha
Copy link
Collaborator

Hi @tarasmorskyi-mediamonks I can reproduce your issue. We'll look into it, in the meantime you can use the following workaround

realm.writeBlocking {
            copyToRealm(sampleEntity).run {
                copyToRealm(SampleChildEntity().apply {
                    childId = "1"
                    title = "one"
                }).also { children.add(it) }

                copyToRealm(SampleChildEntity().apply {
                    childId = "2"
                    title = "two"
                }).also { children.add(it) }
            }

        }

@edualonso
Copy link
Contributor

A fix has been shipped in v0.3.2. Please reopen the issue if the problem still persists.

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

Successfully merging a pull request may close this issue.

4 participants