wvteijlingen / Spine

A Swift library for working with JSON:API APIs. It supports mapping to custom model classes, fetching, advanced querying, linking and persisting.
MIT License
266 stars 109 forks source link

Fix arbitrary filters #84

Closed invliD closed 8 years ago

invliD commented 8 years ago

Unfortunately, I made a mistake in #83 that still prevented arbitrary filters from working. This PR fixes the issue when converting a query to a URL and also adds unit tests for this new use case.

wvteijlingen commented 8 years ago

Thanks! I do have some second thoughts about using the whereAttribute methods for this. The point of the assertions on field names was to notify you when you mistyped an attribute name. To me, passing any random string into whereAttribute feels odd. Perhaps we can create a more general method that allows random filter keys?

wvteijlingen commented 8 years ago

Perhaps we could keep the whereAttribute methods as they were, and add one filterOn(key: String, value: String, type: NSPredicateOperatorType) method to allow custom filtering without duplicating all the whereAttribute methods.

invliD commented 8 years ago

Awesome idea. I'll implement that when I get to it.

wvteijlingen commented 8 years ago

👍