magicalpanda / MagicalRecord

Super Awesome Easy Fetching for Core Data!
Other
10.8k stars 1.79k forks source link

Duplicate records using MR3.0 #1297

Open deepakdhanaie opened 7 years ago

deepakdhanaie commented 7 years ago

I'm using MR 3.0 and importing the objects giving me duplicates.It was working fine in MR 2.3 but when i upgraded to MR 3.0 every time i get duplicates for already saved objects.

    MagicalRecord.saveWithBlock({ (localContext) in

        if let recipeArray = responseDict["recipes"] as? [[String : AnyObject]]{

            for  responseDict in recipeArray {
             Recipe.MR_importFromObject(badgesRecipeDict, inContext: localContext) as! Recipe

        }

        }) { (contextDidSave , error) -> Void in

            if(contextDidSave){   
            }
            else{

            }

    }

I have used relatedByAttribute key in userInfo in Database Schema as well and I'm not able to find the solution for this.

rex3du commented 7 years ago

hey, there the release version is 2.3.3, where do you get the MR 3.0 ?

vishaldeshai commented 6 years ago

Plz use same code as you used for add record but use attributes with primary key for e.g take a key like 'ID' as a primary. when you save(update) then record will be updated.