Skip to content

Commit e178083

Browse files
committed
Change internal parameter prefix to @param to avoid conflict with build indexer records
1 parent 57e8206 commit e178083

2 files changed

Lines changed: 7 additions & 7 deletions

File tree

Sources/CosmoMSSQL/MSSQLConnection.swift

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -563,15 +563,15 @@ public final class MSSQLConnection: SQLDatabase, AdvancedSQLDatabase, @unchecked
563563
try await execute(sql, binds)
564564
}
565565

566-
/// Replace `?` positional placeholders with `@p1`, `@p2`, ... (SQL Server sp_executesql style).
567-
/// If the SQL already uses `@p` style, it is returned unchanged.
566+
/// Replace `?` positional placeholders with `@param1`, `@param2`, ... (SQL Server sp_executesql style).
567+
/// If the SQL already uses `@p` or `@param` style, it is returned unchanged.
568568
static func convertPlaceholders(_ sql: String) -> String {
569569
guard sql.contains("?") else { return sql }
570570
var result = ""
571571
var index = 1
572572
for ch in sql {
573573
if ch == "?" {
574-
result += "@p\(index)"
574+
result += "@param\(index)"
575575
index += 1
576576
} else {
577577
result.append(ch)

Sources/CosmoMSSQL/TDS/TDSRPCRequest.swift

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -47,9 +47,9 @@ struct TDSRPCRequest {
4747
// Option flags: none
4848
buf.writeInteger(UInt16(0), endianness: .little)
4949

50-
// Build the parameter declaration string: "@p1 INT, @p2 NVARCHAR(MAX), ..."
50+
// Build the parameter declaration string: "@param1 INT, @param2 NVARCHAR(MAX), ..."
5151
let decl = binds.enumerated().map { (i, v) in
52-
"@p\(i+1) \(v.tdsTypeName)"
52+
"@param\(i+1) \(v.tdsTypeName)"
5353
}.joined(separator: ", ")
5454

5555
// Param 1: @stmt — the SQL text (unnamed, NVARCHAR(MAX) PLP)
@@ -58,9 +58,9 @@ struct TDSRPCRequest {
5858
// Param 2: @params — declaration string (unnamed, NVARCHAR(MAX) PLP)
5959
writeNVarCharMaxParam(name: "", value: decl, into: &buf)
6060

61-
// Param 3+: @p1, @p2, ... with typed binary values
61+
// Param 3+: @param1, @param2, ... with typed binary values
6262
for (i, bind) in binds.enumerated() {
63-
writeParam(name: "@p\(i+1)", value: bind, into: &buf)
63+
writeParam(name: "@param\(i+1)", value: bind, into: &buf)
6464
}
6565

6666
return buf

0 commit comments

Comments
 (0)