Skip to content

Commit 857e71c

Browse files
committed
remove map_set
1 parent 4eb402e commit 857e71c

File tree

3 files changed

+0
-178
lines changed

3 files changed

+0
-178
lines changed

Firestore/Swift/Source/ExpressionImplementation.swift

Lines changed: 0 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -789,20 +789,6 @@ public extension Expression {
789789
return FunctionExpression(functionName: "map_merge", args: [self] + maps)
790790
}
791791

792-
func mapSet(key: Expression, value: Sendable) -> FunctionExpression {
793-
return FunctionExpression(
794-
functionName: "map_set",
795-
args: [self, key, Helper.sendableToExpr(value)]
796-
)
797-
}
798-
799-
func mapSet(key: String, value: Sendable) -> FunctionExpression {
800-
return FunctionExpression(
801-
functionName: "map_set",
802-
args: [self, Helper.sendableToExpr(key), Helper.sendableToExpr(value)]
803-
)
804-
}
805-
806792
// --- Added Aggregate Operations (on Expr) ---
807793

808794
func countDistinct() -> AggregateFunction {

Firestore/Swift/Source/SwiftAPI/Pipeline/Expressions/Expression.swift

Lines changed: 0 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -1103,34 +1103,6 @@ public protocol Expression: Sendable {
11031103
/// - Returns: A new `FunctionExpression` representing the "map_merge" operation.
11041104
func mapMerge(_ maps: [Expression]) -> FunctionExpression
11051105

1106-
/// Creates an expression that adds or updates a specified field in a map.
1107-
/// Assumes `self` evaluates to a Map, `key` evaluates to a string, and `value` can be
1108-
/// any type.
1109-
///
1110-
/// ```swift
1111-
/// // Set a field using a key from another field
1112-
/// Field("config").mapSet(key: Field("keyName"), value: Field("keyValue"))
1113-
/// ```
1114-
///
1115-
/// - Parameter key: An `Expression` (evaluating to a string) representing the key of
1116-
/// the field to set or update.
1117-
/// - Parameter value: The `Expression` representing the value to set for the field.
1118-
/// - Returns: A new `FunctionExpression` representing the map with the updated field.
1119-
func mapSet(key: Expression, value: Sendable) -> FunctionExpression
1120-
1121-
/// Creates an expression that adds or updates a specified field in a map.
1122-
/// Assumes `self` evaluates to a Map.
1123-
///
1124-
/// ```swift
1125-
/// // Set the "status" field to "active" in the "order" map
1126-
/// Field("order").mapSet(key: "status", value: "active")
1127-
/// ```
1128-
///
1129-
/// - Parameter key: The literal string key of the field to set or update.
1130-
/// - Parameter value: The `Sendable` literal value to set for the field.
1131-
/// - Returns: A new `FunctionExpression` representing the map with the updated field.
1132-
func mapSet(key: String, value: Sendable) -> FunctionExpression
1133-
11341106
// MARK: Aggregations
11351107

11361108
/// Creates an aggregation that counts the number of distinct values of this expression.

Firestore/Swift/Tests/Integration/PipelineTests.swift

Lines changed: 0 additions & 136 deletions
Original file line numberDiff line numberDiff line change
@@ -3107,142 +3107,6 @@ class PipelineIntegrationTests: FSTIntegrationTestCase {
31073107
}
31083108
}
31093109

3110-
func testMapSetAddsNewField() async throws {
3111-
let collRef = collectionRef(withDocuments: bookDocs)
3112-
let db = collRef.firestore
3113-
3114-
let pipeline = db.pipeline()
3115-
.collection(collRef.path)
3116-
.where(Field("title").equal("The Hitchhiker's Guide to the Galaxy"))
3117-
.select([
3118-
Field("awards").mapSet(key: "newAward", value: true).as("modifiedAwards"),
3119-
Field("title"),
3120-
])
3121-
3122-
let snapshot = try await pipeline.execute()
3123-
3124-
XCTAssertEqual(snapshot.results.count, 1, "Should retrieve one document")
3125-
if let resultDoc = snapshot.results.first {
3126-
let expectedAwards: [String: Sendable?] = [
3127-
"hugo": true,
3128-
"nebula": false,
3129-
"others": ["unknown": ["year": 1980]],
3130-
"newAward": true,
3131-
]
3132-
let expectedResult: [String: Sendable?] = [
3133-
"title": "The Hitchhiker's Guide to the Galaxy",
3134-
"modifiedAwards": expectedAwards,
3135-
]
3136-
TestHelper.compare(pipelineResult: resultDoc, expected: expectedResult)
3137-
} else {
3138-
XCTFail("No document retrieved for testMapSetAddsNewField")
3139-
}
3140-
}
3141-
3142-
func testMapSetUpdatesExistingField() async throws {
3143-
let collRef = collectionRef(withDocuments: bookDocs)
3144-
let db = collRef.firestore
3145-
3146-
let pipeline = db.pipeline()
3147-
.collection(collRef.path)
3148-
.where(Field("title").equal("The Hitchhiker's Guide to the Galaxy"))
3149-
.select([
3150-
Field("awards").mapSet(key: "hugo", value: false).as("modifiedAwards"),
3151-
Field("title"),
3152-
])
3153-
3154-
let snapshot = try await pipeline.execute()
3155-
3156-
XCTAssertEqual(snapshot.results.count, 1, "Should retrieve one document")
3157-
if let resultDoc = snapshot.results.first {
3158-
let expectedAwards: [String: Sendable?] = [
3159-
"hugo": false,
3160-
"nebula": false,
3161-
"others": ["unknown": ["year": 1980]],
3162-
]
3163-
let expectedResult: [String: Sendable?] = [
3164-
"title": "The Hitchhiker's Guide to the Galaxy",
3165-
"modifiedAwards": expectedAwards,
3166-
]
3167-
TestHelper.compare(pipelineResult: resultDoc, expected: expectedResult)
3168-
} else {
3169-
XCTFail("No document retrieved for testMapSetUpdatesExistingField")
3170-
}
3171-
}
3172-
3173-
func testMapSetWithExpressionValue() async throws {
3174-
let collRef = collectionRef(withDocuments: bookDocs)
3175-
let db = collRef.firestore
3176-
3177-
let pipeline = db.pipeline()
3178-
.collection(collRef.path)
3179-
.where(Field("title").equal("The Hitchhiker's Guide to the Galaxy"))
3180-
.select(
3181-
[
3182-
Field("awards")
3183-
.mapSet(
3184-
key: "ratingCategory",
3185-
value: Field("rating").greaterThan(4.0).then(Constant("high"), else: Constant("low"))
3186-
)
3187-
.as("modifiedAwards"),
3188-
Field("title"),
3189-
]
3190-
)
3191-
3192-
let snapshot = try await pipeline.execute()
3193-
3194-
XCTAssertEqual(snapshot.results.count, 1, "Should retrieve one document")
3195-
if let resultDoc = snapshot.results.first {
3196-
let expectedAwards: [String: Sendable?] = [
3197-
"hugo": true,
3198-
"nebula": false,
3199-
"others": ["unknown": ["year": 1980]],
3200-
"ratingCategory": "high",
3201-
]
3202-
let expectedResult: [String: Sendable?] = [
3203-
"title": "The Hitchhiker's Guide to the Galaxy",
3204-
"modifiedAwards": expectedAwards,
3205-
]
3206-
TestHelper.compare(pipelineResult: resultDoc, expected: expectedResult)
3207-
} else {
3208-
XCTFail("No document retrieved for testMapSetWithExpressionValue")
3209-
}
3210-
}
3211-
3212-
func testMapSetWithExpressionKey() async throws {
3213-
let collRef = collectionRef(withDocuments: bookDocs)
3214-
let db = collRef.firestore
3215-
3216-
let pipeline = db.pipeline()
3217-
.collection(collRef.path)
3218-
.where(Field("title").equal("The Hitchhiker's Guide to the Galaxy"))
3219-
.select([
3220-
Field("awards")
3221-
.mapSet(key: Constant("dynamicKey"), value: "dynamicValue")
3222-
.as("modifiedAwards"),
3223-
Field("title"),
3224-
])
3225-
3226-
let snapshot = try await pipeline.execute()
3227-
3228-
XCTAssertEqual(snapshot.results.count, 1, "Should retrieve one document")
3229-
if let resultDoc = snapshot.results.first {
3230-
let expectedAwards: [String: Sendable?] = [
3231-
"hugo": true,
3232-
"nebula": false,
3233-
"others": ["unknown": ["year": 1980]],
3234-
"dynamicKey": "dynamicValue",
3235-
]
3236-
let expectedResult: [String: Sendable?] = [
3237-
"title": "The Hitchhiker's Guide to the Galaxy",
3238-
"modifiedAwards": expectedAwards,
3239-
]
3240-
TestHelper.compare(pipelineResult: resultDoc, expected: expectedResult)
3241-
} else {
3242-
XCTFail("No document retrieved for testMapSetWithExpressionKey")
3243-
}
3244-
}
3245-
32463110
func testSupportsTimestampConversions() async throws {
32473111
let db = firestore()
32483112
let randomCol = collectionRef() // Unique collection for this test

0 commit comments

Comments
 (0)