CloudKit Query for String Match Fails on Certain Strings?

I am saving the userCloudId.recordName (from CKContainer.default().fetchUserRecordID()) as a string to a field called "loginId" in a custom table called "Employee" in my public iCloud database, the value looks something like this "_aebcd4c5af42dab942e1c094c4e2fc04".


I have some friends log into my app with their iCloud Users and some can see data and others cannot.


When I dig deeper, it appears that fetching by certain userCloudId.recordName strings work and others do not. I even try to fetch inside of the cloudkit dashboard and some of these show results and others show no records, even though I'm taking these strings directly from the records I'm browsing through.


  1. I just manually scroll to an "Employee" record in CloudKit dashboard
  2. I copy the "loginId" value
  3. Paste it directly in the "loginId" filter in CloudKit dashboard for employee table
  4. Tap Query Records and it says No Records Found.


If I browse to a different loginId, it returns the correct record. I'm at a complete loss as to why this is happening.


I use iCloud in many of my apps and this is the first time something like this is happening to me. Any ideas?


This is on iOS12, devices I tried are iPhone X and iPhone XR but these seem irrelevant.

Accepted Reply

Nevermind. Woke up the next day and all records are fetching correctly.


What appears to have happened is, the loginIds that could be fetched were added that morning and the newly inserted ones from last night could not be fetched.


Last night, as a test, I created a new dummy table with 1 string field, added 3 records to it and all 3 could not be fetched, not even by the fetchAll recordName query. This morning all 3 records can be fetched just fine...


So last night something was very strange where we could write to cloudkit but all fetches happened against some cache of older data? which caused my issues. Pretty wonky, seems like it was like this for a few hours at least while I was running my tests.

Replies

Nevermind. Woke up the next day and all records are fetching correctly.


What appears to have happened is, the loginIds that could be fetched were added that morning and the newly inserted ones from last night could not be fetched.


Last night, as a test, I created a new dummy table with 1 string field, added 3 records to it and all 3 could not be fetched, not even by the fetchAll recordName query. This morning all 3 records can be fetched just fine...


So last night something was very strange where we could write to cloudkit but all fetches happened against some cache of older data? which caused my issues. Pretty wonky, seems like it was like this for a few hours at least while I was running my tests.