Note that there are some explanatory texts on larger screens.

plurals
  1. PONSPredicate not executed
    primarykey
    data
    text
    <p>This is quite funny. In my application I create thousands of entry in the database (in another thread, I'm using MagicalRecord). Everything seems working fine (from a background/foreground/context point of view).</p> <p>When, in the main thread, I try to fetch the "just inserted" data, I discovered the following behaviour:</p> <pre><code>- (NSArray *) familiesInCompany:(Company *) company { NSPredicate *predicate1 = [NSPredicate predicateWithFormat:@"company == %@", company]; NSPredicate *predicate2 = [NSPredicate predicateWithFormat:@"company.name == %@", company.name]; NSArray *first = [Family MR_findAllSortedBy:@"name" ascending:YES withPredicate:predicate1]; NSArray *second = [Family MR_findAllSortedBy:@"name" ascending:YES withPredicate:predicate2]; NSArray *third = [Family MR_findByAttribute:@"company" withValue:company andOrderBy:@"name" ascending:YES]; return second; } </code></pre> <p>Now what I get is:</p> <ul> <li>first: is an empty array</li> <li>second: contains all the <code>Family</code> objects, as expected</li> <li>third: is an empty array.</li> </ul> <p>By debugging the SQL statement I get the following:</p> <p>The "first" statement:</p> <blockquote> <p>CoreData: annotation: total fetch execution time: 0.0000s for 0 rows.</p> </blockquote> <p>The "second" statement":</p> <blockquote> <p>CoreData: sql: SELECT 0, t0.Z_PK, t0.Z_OPT, t0.ZNAME, t0.ZCOMPANY FROM ZFAMILY t0 JOIN ZCOMPANY t1 ON t0.ZCOMPANY = t1.Z_PK WHERE t1.ZNAME = ? ORDER BY t0.ZNAME</p> <p>CoreData: annotation: sql connection fetch time: 0.0005s</p> <p>CoreData: annotation: total fetch execution time: 0.0007s for 2 rows.</p> </blockquote> <p>The "third" statement:</p> <blockquote> <p>CoreData: annotation: total fetch execution time: 0.0000s for 0 rows.</p> </blockquote> <p>The hilarious thing is that I close the application (I mean really manually terminate it) and and I open it back, all the three "fetching" statements work.</p> <p>Why the first and the third fetch statements seem to never being executed? How to dig into the problem?</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload