Code Monkey home page Code Monkey logo

datafilter's People

Contributors

0ff avatar 3lvis avatar francisbehnen avatar kostiakoval avatar nselvis avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar

datafilter's Issues

Provide error instead of crashing when multiple instances of the same primary key are found

Hi again.

The only crash I really care about now is the last one in DATAFilter. From my observation, it happens when the primary keys are not unique (e.g. when the JSON contains multiple primary keys of equal values).

While I agree that it should not really happen if everything is correctly set up, it can't be guaranteed that the output from JSON is valid.

I think in this case, the error could be easily caught (if changes.count != remoteObjectIDs.count on line 42 in DATAFilter.m) and probably just throw an error.

I'm pretty busy right now, but I can try to find some time for a pull request if needed.

3lvis/Sync#224

Swiftify master

Current master still makes heavily use of ObjC types and methods. It's probably better to minimise this.

@3lvis I can work on this if you haven't started with it yet.

0.8.3 causes issue with ordered sets

Hey @3lvis!

I'm using Sync in a project and have an ordered relationship in my Core Data model. Previously, Sync had been handling this correctly and the objects were mapped to my Core Data ordered set in the same order they were in the JSON. After updating to the latest Sync, however, I noticed the objects were no longer in order. It appears that the issue is with DATAFilter 0.8.3. After reverting to 0.8.2, it works again as expected.

Type mismatch in IDs make DATAFilter delete and create semantically identical objects

If there is a type mismatch for the identifier in what is in the JSON from what is in the NSManagedObject definition, DATAFilter will fail to see that the objects are identical and will delete and recreate it.

For example, if such JSON is returned (if localKey is remoteID and remoteKey is remoteID):

[
  {
    "id": 30,
    ...
  }
]

And in the NSManagedObject definition, remoteID is of type string and has the value "30", what I described above will happen (Because in the JSON, the identifier will be of type NSNumber and in the NSManagedObject of type NSString)

The method responsible for this seems to be [+DATAFilter changes:inEntityNamed:localKey:remoteKey:context:predicate:inserted:updated:], on the line [intersection intersectSet:[NSSet setWithArray:fetchedObjectIDs]];
The NSSet will use the method isEqual and determines that a NSNumber can't be equal to a NSString (In my example)

I can submit a pull request that fixes the issue by always converting all identifiers (remote and local) to NSString prior to doing the intersection (using [-NSObject description]. What do you think?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.