diff --git a/CHANGELOG.md b/CHANGELOG.md index 90cb363b1..bdf2ef89f 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,9 +2,15 @@ ### main -[Full Changelog](https://github.com/parse-community/Parse-Swift/compare/4.1.0...main) +[Full Changelog](https://github.com/parse-community/Parse-Swift/compare/4.2.0...main) * _Contributing to this repo? Add info about your change here to be included in the next release_ +### 4.2.0 +[Full Changelog](https://github.com/parse-community/Parse-Swift/compare/4.1.0...4.2.0) + +__New features__ +- Add variadic QueryConstraint methods for or, nor, and ([#345](https://github.com/parse-community/Parse-Swift/pull/345)), thanks to [Corey Baker](https://github.com/cbaker6). + __Improvements__ - Add clientDefault static property to ParseLiveQuery which replaces the getDefault() method. getDefault() is still avaiable, but will be deprecated in ParseSwift 5.0.0 so it is recommended to switch to clientDefault ([#342](https://github.com/parse-community/Parse-Swift/pull/342)), thanks to [Corey Baker](https://github.com/cbaker6). diff --git a/Sources/ParseSwift/ParseConstants.swift b/Sources/ParseSwift/ParseConstants.swift index 5ae0ce9c8..912745ece 100644 --- a/Sources/ParseSwift/ParseConstants.swift +++ b/Sources/ParseSwift/ParseConstants.swift @@ -10,7 +10,7 @@ import Foundation enum ParseConstants { static let sdk = "swift" - static let version = "4.1.0" + static let version = "4.2.0" static let fileManagementDirectory = "parse/" static let fileManagementPrivateDocumentsDirectory = "Private Documents/" static let fileManagementLibraryDirectory = "Library/" diff --git a/Sources/ParseSwift/Types/ParsePolygon.swift b/Sources/ParseSwift/Types/ParsePolygon.swift index d7464faa9..f2f9c107c 100644 --- a/Sources/ParseSwift/Types/ParsePolygon.swift +++ b/Sources/ParseSwift/Types/ParsePolygon.swift @@ -32,7 +32,7 @@ public struct ParsePolygon: Codable, Hashable { /** Create new `ParsePolygon` instance with a variadic amount of coordinates. - - parameter coordinates: variadic amount of zero or more `ParseGeoPoint`'s. + - parameter coordinates: variadic amount of zero or more `ParseGeoPoint`'s. - throws: An error of type `ParseError`. */ public init(_ coordinates: ParseGeoPoint...) throws { diff --git a/Sources/ParseSwift/Types/QueryConstraint.swift b/Sources/ParseSwift/Types/QueryConstraint.swift index 147a3c21f..a4b09ebc1 100644 --- a/Sources/ParseSwift/Types/QueryConstraint.swift +++ b/Sources/ParseSwift/Types/QueryConstraint.swift @@ -273,6 +273,15 @@ public func or (queries: [Query]) -> QueryConstraint where T: ParseObject return QueryConstraint(key: QueryConstraint.Comparator.or.rawValue, value: orQueries) } +/** + Returns a `Query` that is the `or` of the passed in queries. + - parameter queries: The variadic amount of queries to `or` together. + - returns: An instance of `QueryConstraint`'s that are the `or` of the passed in queries. + */ +public func or (queries: Query...) -> QueryConstraint where T: ParseObject { + or(queries: queries) +} + /** Returns a `Query` that is the `nor` of the passed in queries. - parameter queries: The list of queries to `nor` together. @@ -283,12 +292,21 @@ public func nor (queries: [Query]) -> QueryConstraint where T: ParseObject return QueryConstraint(key: QueryConstraint.Comparator.nor.rawValue, value: orQueries) } +/** + Returns a `Query` that is the `nor` of the passed in queries. + - parameter queries: The variadic amount of queries to `nor` together. + - returns: An instance of `QueryConstraint`'s that are the `nor` of the passed in queries. + */ +public func nor (queries: Query...) -> QueryConstraint where T: ParseObject { + nor(queries: queries) +} + /** Constructs a Query that is the `and` of the passed in queries. For example: - var compoundQueryConstraints = and(query1, query2, query3) + var compoundQueryConstraints = and([query1, query2, query3]) will create a compoundQuery that is an and of the query1, query2, and query3. - parameter queries: The list of queries to `and` together. @@ -299,6 +317,21 @@ public func and (queries: [Query]) -> QueryConstraint where T: ParseObject return QueryConstraint(key: QueryConstraint.Comparator.and.rawValue, value: andQueries) } +/** + Constructs a Query that is the `and` of the passed in queries. + + For example: + + var compoundQueryConstraints = and(query1, query2, query3) + + will create a compoundQuery that is an and of the query1, query2, and query3. + - parameter queries: The variadic amount of queries to `and` together. + - returns: An instance of `QueryConstraint`'s that are the `and` of the passed in queries. +*/ +public func and (queries: Query...) -> QueryConstraint where T: ParseObject { + and(queries: queries) +} + /** Add a constraint that requires that a key's value matches a `Query` constraint. - warning: This only works where the key's values are `ParseObject`s or arrays of `ParseObject`s. diff --git a/Tests/ParseSwiftTests/ParseQueryTests.swift b/Tests/ParseSwiftTests/ParseQueryTests.swift index 0e9b4744c..1401046e5 100644 --- a/Tests/ParseSwiftTests/ParseQueryTests.swift +++ b/Tests/ParseSwiftTests/ParseQueryTests.swift @@ -1741,7 +1741,7 @@ class ParseQueryTests: XCTestCase { // swiftlint:disable:this type_body_length ] let query1 = GameScore.query("points" <= 50) let query2 = GameScore.query("points" <= 200) - let constraint = or(queries: [query1, query2]) + let constraint = or(queries: query1, query2) let query = Query(constraint) let queryWhere = query.`where` @@ -1772,7 +1772,7 @@ class ParseQueryTests: XCTestCase { // swiftlint:disable:this type_body_length ] let query1 = GameScore.query("points" <= 50) let query2 = GameScore.query("points" <= 200) - let constraint = nor(queries: [query1, query2]) + let constraint = nor(queries: query1, query2) let query = Query(constraint) let queryWhere = query.`where` @@ -1803,7 +1803,7 @@ class ParseQueryTests: XCTestCase { // swiftlint:disable:this type_body_length ] let query1 = GameScore.query("points" <= 50) let query2 = GameScore.query("points" <= 200) - let constraint = and(queries: [query1, query2]) + let constraint = and(queries: query1, query2) let query = Query(constraint) let queryWhere = query.`where`