Partial Sync never resolves

cloud

#1

I’m using Realm Cloud for my Android project, and have it set up currently where each user has a User parent Realm object that contains lists of data for that user. When I go to fetch that user from the cloud if I’m using partial sync the user never becomes valid (user.isValid() never returns true), whereas if I have the exact same code other than simply specifying fullSynchronization when building the config the user is initially invalid but updates with the proxy in short order.

This only thing that changes is the below:

Realm.setDefaultConfiguration(SyncUser.current().createConfiguration("$REALM_BASE_URL/default2").fullSynchronization().build())

For partial sync I simply remove the fullsync method as the default is partial.

My getUser method looks like this:

fun getUser(realm: Realm, changeListener: RealmChangeListener<User>? = null): User {
        val user = realm.where(User::class.java).equalTo("userId", FirebaseAuth.getInstance().currentUser!!.uid).findFirstAsync()
        if (changeListener != null) {
            user.addChangeListener(changeListener::onChange)
        }
        return user
    }

Note the change listener will be called when using partial or full sync once the query resolves (presumably that’s what’s happening at least, it’s fired off shortly after in either case), it’s just that in partial sync the user I get back isn’t valid, while on full sync it is.

Any ideas what I’m doing wrong here? Thanks!


#2

Was this a bad question (in that I’m doing something stupid that’s well-documented somewhere and/or I haven’t provided enough information to assist)?


#3

@chronofar Please always share the logs when you are having an issue like this - likely this has the answer. I would guess that your Realm is of full type that is for FullSync and you need to convert it to reference to use it for partial sync. You can change to reference by clicking on the Realm in Studio and click the Upgrade button