You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Add missing query parameters filters and numericFilters
The rationale for not implementing them was that they cannot be adequately typed. However, after investigation:
- `numericFilters` has roughly the same complexity as `tagFilters` or `facetFilters`. Therefore using a JSON array type, like for those parameters, should be adequate (although suboptimal).
- `filters` is designed to be a “SQL-like notation”, so I guess a raw string type is adequate. In the future, we may want to provide tools to build the filters more easily, but this will likely come in the form of “helpers”, as it is done in the Javascript client.
Since the absence of typed properties for the missing parameters was confusing, I am adding them now.
Copy file name to clipboardExpand all lines: Tests/QueryTests.swift
+23Lines changed: 23 additions & 0 deletions
Original file line number
Diff line number
Diff line change
@@ -617,4 +617,27 @@ class QueryTests: XCTestCase {
617
617
letquery2=Query.parse(query1.build())
618
618
XCTAssertEqual(query2.minimumAroundRadius,1000)
619
619
}
620
+
621
+
func test_numericFilters(){
622
+
letVALUE:[AnyObject]=["code=1",["price:0 to 10","price:1000 to 2000"]]
623
+
letquery1=Query()
624
+
XCTAssertNil(query1.numericFilters)
625
+
query1.numericFilters = VALUE
626
+
XCTAssertEqual(query1.numericFilters! asNSObject, VALUE asNSObject)
627
+
XCTAssertEqual(query1["numericFilters"],"[\"code=1\",[\"price:0 to 10\",\"price:1000 to 2000\"]]")
628
+
letquery2=Query.parse(query1.build())
629
+
XCTAssertEqual(query2.numericFilters! asNSObject, VALUE asNSObject)
630
+
}
631
+
632
+
func test_filters(){
633
+
letVALUE="available=1 AND (category:Book OR NOT category:Ebook) AND publication_date: 1441745506 TO 1441755506 AND inStock > 0 AND author:\"John Doe\""
0 commit comments