Skip to content

Commit 617feb4

Browse files
committed
rename substring
1 parent 3d0a3d3 commit 617feb4

File tree

3 files changed

+16
-18
lines changed

3 files changed

+16
-18
lines changed

Firestore/Swift/Source/ExpressionImplementation.swift

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -671,20 +671,20 @@ public extension Expression {
671671
return FunctionExpression("byte_length", [self])
672672
}
673673

674-
func substr(position: Int, length: Int? = nil) -> FunctionExpression {
674+
func substring(position: Int, length: Int? = nil) -> FunctionExpression {
675675
let positionExpr = Helper.sendableToExpr(position)
676676
if let length = length {
677-
return FunctionExpression("substr", [self, positionExpr, Helper.sendableToExpr(length)])
677+
return FunctionExpression("substring", [self, positionExpr, Helper.sendableToExpr(length)])
678678
} else {
679-
return FunctionExpression("substr", [self, positionExpr])
679+
return FunctionExpression("substring", [self, positionExpr])
680680
}
681681
}
682682

683-
func substr(position: Expression, length: Expression? = nil) -> FunctionExpression {
683+
func substring(position: Expression, length: Expression? = nil) -> FunctionExpression {
684684
if let length = length {
685-
return FunctionExpression("substr", [self, position, length])
685+
return FunctionExpression("substring", [self, position, length])
686686
} else {
687-
return FunctionExpression("substr", [self, position])
687+
return FunctionExpression("substring", [self, position])
688688
}
689689
}
690690

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

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -953,16 +953,16 @@ public protocol Expression: Sendable {
953953
///
954954
/// ```swift
955955
/// // Get substring from index 5 with length 10
956-
/// Field("myString").substr(5, 10)
956+
/// Field("myString").substring(5, 10)
957957
///
958958
/// // Get substring from "myString" starting at index 3 to the end
959-
/// Field("myString").substr(3, nil)
959+
/// Field("myString").substring(3, nil)
960960
/// ```
961961
///
962962
/// - Parameter position: Literal `Int` index of the first character/byte.
963963
/// - Parameter length: Optional literal `Int` length of the substring. If `nil`, goes to the end.
964964
/// - Returns: A new `FunctionExpr` representing the substring.
965-
func substr(position: Int, length: Int?) -> FunctionExpression
965+
func substring(position: Int, length: Int?) -> FunctionExpression
966966

967967
/// Creates an expression that returns a substring of this expression (String or Bytes) using
968968
/// expressions for position and optional length.
@@ -973,18 +973,18 @@ public protocol Expression: Sendable {
973973
///
974974
/// ```swift
975975
/// // Get substring from index calculated by Field("start") with length from Field("len")
976-
/// Field("myString").substr(Field("start"), Field("len"))
976+
/// Field("myString").substring(Field("start"), Field("len"))
977977
///
978978
/// // Get substring from index calculated by Field("start") to the end
979-
/// Field("myString").substr(Field("start"), nil) // Passing nil for optional Expr length
979+
/// Field("myString").substring(Field("start"), nil) // Passing nil for optional Expr length
980980
/// ```
981981
///
982982
/// - Parameter position: An `Expr` (evaluating to an Int) for the index of the first
983983
/// character/byte.
984984
/// - Parameter length: Optional `Expr` (evaluating to an Int) for the length of the substring. If
985985
/// `nil`, goes to the end.
986986
/// - Returns: A new `FunctionExpr` representing the substring.
987-
func substr(position: Expression, length: Expression?) -> FunctionExpression
987+
func substring(position: Expression, length: Expression?) -> FunctionExpression
988988

989989
// MARK: Map Operations
990990

Firestore/Swift/Tests/Integration/PipelineTests.swift

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3216,30 +3216,28 @@ class PipelineIntegrationTests: FSTIntegrationTestCase {
32163216
)
32173217
}
32183218

3219-
func testSubstr() async throws {
3220-
try XCTSkipIf(true, "Skip this test since backend has not yet supported.")
3219+
func testSubstring() async throws {
32213220
let collRef = collectionRef(withDocuments: bookDocs)
32223221
let db = collRef.firestore
32233222

32243223
let pipeline = db.pipeline()
32253224
.collection(collRef.path)
32263225
.sort([Field("rating").descending()])
32273226
.limit(1)
3228-
.select([Field("title").substr(position: 9, length: 2).as("of")])
3227+
.select([Field("title").substring(position: 9, length: 2).as("of")])
32293228
let snapshot = try await pipeline.execute()
32303229
TestHelper.compare(pipelineSnapshot: snapshot, expected: [["of": "of"]], enforceOrder: false)
32313230
}
32323231

3233-
func testSubstrWithoutLength() async throws {
3234-
try XCTSkipIf(true, "Skip this test since backend has not yet supported.")
3232+
func testSubstringWithoutLength() async throws {
32353233
let collRef = collectionRef(withDocuments: bookDocs)
32363234
let db = collRef.firestore
32373235

32383236
let pipeline = db.pipeline()
32393237
.collection(collRef.path)
32403238
.sort([Field("rating").descending()])
32413239
.limit(1)
3242-
.select([Field("title").substr(position: 9).as("of")])
3240+
.select([Field("title").substring(position: 9).as("of")])
32433241
let snapshot = try await pipeline.execute()
32443242
TestHelper.compare(
32453243
pipelineSnapshot: snapshot,

0 commit comments

Comments
 (0)