mirror of
https://github.com/JohnEstropia/CoreStore.git
synced 2026-01-11 20:00:30 +01:00
Question: query works but Relationship objects empty #359
Reference in New Issue
Block a user
Delete Branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Originally created by @nneuberger1 on GitHub (Mar 19, 2021).
I can query an a primary object based on the data of a secondary relationship object like:
let localMediaUserDetail = try dataStack.fetchOne(From().where(.$mediaData ~ .$identifier == "1000"))
But after retrieving the data, I get an nil object associated on that relationship.
if let mediaData = localMediaUserDetails.mediaData {
print("!--")
print("!-- mediaData")
print("!-- identifer: (mediaData.identifier)")
print("!-- title: (mediaData.title)")
}
The above is never hit.
Here's part of my configuration:
public class LocalMediaUserDetail: CoreStoreObject {
}
and the related class
public class LocalMediaData: CoreStoreObject {
// parent
@Field.Relationship("mediaUserDetail")
var mediaUserDetail: LocalMediaUserDetail?
}
Is there something I'm doing wrong?
My google query kung fu` has been exhausted so I posted the question.. ;-)
@JohnEstropia commented on GitHub (Mar 19, 2021):
Have you tried to query for just the relationship object? It's possible the object isn't getting saved (yet), maybe due to a transaction error or a timing issue
@nneuberger1 commented on GitHub (Mar 19, 2021):
Do you mean directly querying the relationship like this? I do get a record back. But possible error that might be a cause?
Results in:
!-- localMediaData found
2021-03-18 22:43:33.413047-0500 ThingsAboveIOS QA[24096:818105] [error] error: API Misuse: Attempt to serialize store access on non-owning coordinator (PSC = 0x600001b357a0, store PSC = 0x0)
CoreData: error: API Misuse: Attempt to serialize store access on non-owning coordinator (PSC = 0x600001b357a0, store PSC = 0x0)
!-- localMediaUserDetail NOT found
@nneuberger1 commented on GitHub (Mar 19, 2021):
If it helps, maybe I'm saving them improperly. I do get a success response on the completion.
dataStack.perform(
asynchronous: { (transaction) -> Void in
@nneuberger1 commented on GitHub (Mar 19, 2021):
I'm using the SQLiteStore as well on setup of the dataStack.
@JohnEstropia commented on GitHub (Apr 13, 2021):
@nneuberger1 Apologies for going silent here, but have you sorted it out?
A quick google of the error
shows this is likely a multithreading issue. Are you sure your
dataStack.fetch*()calls are running in the main queue?