Core Data generates invalid SQL statement

I have been having issues with the app crawling to a hault. After much agony, I was able to narrow the cause down to this: Core Data generates an invalid SQL statement and Core Data disconnect from SQL DB, then tries to recover only to fail again. The invalid SQL statement that caused the connection to end is:


CoreData: sql: SELECT Z_PK, Z_ENT, ZNODEID, ZALBUMID FROM ZNODE WHERE (ZNODEID IN (? , ? , ? ) OR (ZALBUMID IN (? , ? , ? ))


Please note the extra "

(
" before
ZALBUMID
. Either that or we can remove open parenthesis before
ZNODEID
and it will work.

The error I am getting is:

2016-08-05 23:24:25.858 STV[31710:5515735] CoreData: annotation: Disconnecting from sqlite database due to an error.

2016-08-05 23:24:25.859 STV[31710:5515735] CoreData: error: (1) I/O error for database at /Users/skim/Library/Developer/CoreSimulator/Devices/E4B4DE09-F416-4792-AD35-550A38EAF6E2/data/Containers/Shared/AppGroup/FA274416-D266-41D3-84C1-D6AAE22D76F8/Library/Caches/STV.sqlite. SQLite error code:1, 'near ")": syntax error'

2016-08-05 23:24:25.860 STV[31710:5515735] CoreData: annotation: Connecting to sqlite databaite"

These series of events cause the app to crawl to a hault. I was hoping someone at Apple had a suggestion as to how I can avoid this error (workaround) until it is fixed. Deadline looms and I really do need this fixed. I would really appreciate anyone's help on this. Thanks!


FYI: Some background information.

Node
an abstract entity which concrete entities
Album
and
Folder
entities inherit from. There are no predicates in my code that attempts to fetch
nodeID
and
albumID
using
nodeID IN (%@) OR albumID IN (%@)
syntax. I do believe this is generated by Core Data in maintaining related entities.

There are two standard questions:


1. What are you doing which causes the invalid SQL statement? Do you have a reproducible test case?

2. What's your bug report number? If you don't have a bug report number, you need to file a bug report with the information in your post and the test case if you have one.

For your question 1, please see the "FYI" section. As for "reproducible test case", no, I have not had the time to extract out the code that can be used to single out the issue I am experiencing. As for question 2, since the app is not ready to be announced and the logs disclose too much information, I will need to file the bug report after I have had some time to sanitize the information. These are all associated with need for time which I have little of. I'll get around to them as soon as I am able.

Core Data generates invalid SQL statement
 
 
Q