Skip to content

Commit 32f014e

Browse files
CopilotThorium
andcommitted
Change .ToUpper() to .ToUpperInvariant() for culture-independent string comparisons
Co-authored-by: Thorium <229355+Thorium@users.noreply.github.com>
1 parent ccdd51e commit 32f014e

9 files changed

Lines changed: 17 additions & 17 deletions

File tree

src/SQLProvider.Common/SqlRuntime.Common.fs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1100,7 +1100,7 @@ module public OfflineTools =
11001100
match dummydata.TryGetValue(arg1.ToLower()) with
11011101
| true, tableData -> createMockEntitiesDc this arg1 tableData
11021102
| false, _ ->
1103-
match dummydata |> Map.toSeq |> Seq.tryFind(fun (k,v) -> k.ToUpper() = arg1.ToUpper()) with
1103+
match dummydata |> Map.toSeq |> Seq.tryFind(fun (k,v) -> k.ToUpperInvariant() = arg1.ToUpperInvariant()) with
11041104
| Some (k, tableData) -> createMockEntitiesDc this arg1 tableData
11051105
| None -> failwith ("Add table to dummydata: " + arg1)
11061106
member this.CreateEntity(arg1: string): SqlEntity =

src/SQLProvider.Common/Ssdt.DacpacParser.fs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -260,11 +260,11 @@ let parseXml(xml: string) =
260260
let annotation = RegexParsers.parseTableColumnAnnotation colName colExpr
261261
let dataType =
262262
annotation
263-
|> ValueOption.map (fun a -> a.DataType.ToUpper()) // Ucase to match typeMappings
263+
|> ValueOption.map (fun a -> a.DataType.ToUpperInvariant()) // Ucase to match typeMappings
264264
|> ValueOption.defaultValue "SQL_VARIANT"
265265
let allowNulls =
266266
match annotation with
267-
| ValueSome { Nullability = ValueSome nlb } -> nlb.ToUpper() = "NULL"
267+
| ValueSome { Nullability = ValueSome nlb } -> nlb.ToUpperInvariant() = "NULL"
268268
| ValueSome { Nullability = ValueNone } -> true // Sql Server column declarations allow nulls by default
269269
| ValueNone -> false // Default to "SQL_VARIANT" (obj) with no nulls if annotation is not found
270270

@@ -411,7 +411,7 @@ let parseXml(xml: string) =
411411

412412
let parseUserDefinedDataType (uddts: XmlNode) =
413413
let name = uddts |> att "Name"
414-
let name = name |> RegexParsers.splitFullName |> fun parsed -> (String.concat "." parsed).ToUpper() |> UDDTName
414+
let name = name |> RegexParsers.splitFullName |> fun parsed -> (String.concat "." parsed).ToUpperInvariant() |> UDDTName
415415
let inheritedType =
416416
uddts
417417
|> nodes "x:Relationship"
@@ -420,7 +420,7 @@ let parseXml(xml: string) =
420420
|> att "Name"
421421
|> RegexParsers.splitFullName
422422
|> fun parsed -> String.concat "." parsed
423-
|> fun t -> t.ToUpper()
423+
|> fun t -> t.ToUpperInvariant()
424424
|> UDDTInheritedType
425425
(name, inheritedType)
426426

@@ -490,11 +490,11 @@ let parseXml(xml: string) =
490490
// Can't resolve column, or annotation override: try to find a commented type annotation
491491
let dataType =
492492
annotation
493-
|> Option.map (fun a -> a.DataType.ToUpper()) // Ucase to match typeMappings
493+
|> Option.map (fun a -> a.DataType.ToUpperInvariant()) // Ucase to match typeMappings
494494
|> Option.defaultValue "SQL_VARIANT"
495495
let allowNulls =
496496
match annotation with
497-
| Some { Nullability = ValueSome nlb } -> nlb.ToUpper() = "NULL"
497+
| Some { Nullability = ValueSome nlb } -> nlb.ToUpperInvariant() = "NULL"
498498
| Some { Nullability = ValueNone } -> true // Sql Server column declarations allow nulls by default
499499
| None -> false // Default to "SQL_VARIANT" (obj) with no nulls if annotation is not found
500500
let description =

src/SQLProvider.Common/Utils.fs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -270,7 +270,7 @@ module Utilities =
270270
let prefix2 = alias + "."
271271
let prefix3 = "`" + alias + "`."
272272
let prefix4 = alias + "_"
273-
let prefix5 = alias.ToUpper() + "_"
273+
let prefix5 = alias.ToUpperInvariant() + "_"
274274
let prefix6 = "\"" + alias + "\"."
275275
(fun (k:string,v) ->
276276
if k.StartsWith prefix then

src/SQLProvider.DesignTime/SqlDesignTime.fs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -554,7 +554,7 @@ module DesignTimeUtils =
554554
let caseInsensitivityCheck =
555555
match caseSensitivity with
556556
| CaseSensitivityChange.TOLOWER -> (fun (x:string) -> x.ToLower())
557-
| CaseSensitivityChange.TOUPPER -> (fun (x:string) -> x.ToUpper())
557+
| CaseSensitivityChange.TOUPPER -> (fun (x:string) -> x.ToUpperInvariant())
558558
| _ -> id
559559

560560
let conString = ConfigHelpers.tryGetConnectionString false config.ResolutionFolder conStringName connectionString

src/SQLProvider.Runtime/Providers.DuckDb.fs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -202,7 +202,7 @@ module DuckDb =
202202

203203
let dbMappings =
204204
mappings
205-
|> List.map (fun m -> (match m.ProviderTypeName with ValueSome x -> x | ValueNone -> "").ToUpper(), m)
205+
|> List.map (fun m -> (match m.ProviderTypeName with ValueSome x -> x | ValueNone -> "").ToUpperInvariant(), m)
206206
|> Map.ofList
207207

208208
typeMappings <- mappings
@@ -589,7 +589,7 @@ type internal DuckDbProvider(resolutionPath, contextSchemaPath, owner:string, re
589589
let maxlen =
590590
if reader.IsDBNull(2) then ""
591591
else reader.GetValue(2).ToString()
592-
let isUnsigned = not(reader.IsDBNull 6) && reader.GetString(6).ToUpper().Contains("UNSIGNED")
592+
let isUnsigned = not(reader.IsDBNull 6) && reader.GetString(6).ToUpperInvariant().Contains("UNSIGNED")
593593
let udt = if isUnsigned then dt + " unsigned" else dt
594594
match DuckDb.findDbType udt with
595595
| Some(m) ->

src/SQLProvider.Runtime/Providers.MsSqlServer.Dynamic.fs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -331,7 +331,7 @@ module MSSqlServerDynamic =
331331
not <| Set.contains name toFilter)
332332
|> DataTable.map (fun row -> getSprocName row, dbUnbox<string> row.["routine_type"])
333333
|> Seq.map (fun (name, routineType) ->
334-
match routineType.ToUpper() with
334+
match routineType.ToUpperInvariant() with
335335
| "FUNCTION" -> Root("Functions", Sproc({ Name = name; Params = (fun con -> getSprocParameters con name); ReturnColumns = (fun con sparams -> getSprocReturnCols con name sparams) }))
336336
| "PROCEDURE" -> Root("Procedures", Sproc({ Name = name; Params = (fun con -> getSprocParameters con name); ReturnColumns = (fun con sparams -> getSprocReturnCols con name sparams) }))
337337
| _ -> Empty

src/SQLProvider.Runtime/Providers.MsSqlServer.Ssdt.fs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -160,10 +160,10 @@ module MSSqlServerSsdt =
160160
|> Map.ofList
161161

162162
let tryFindMapping (dataType: string) =
163-
typeMappingsByName.TryFind (dataType.ToUpper())
163+
typeMappingsByName.TryFind (dataType.ToUpperInvariant())
164164

165165
let rec tryFindMappingOrVariant (uddts: SsdtUserDefinedDataType) (dataType: string) =
166-
let dataType = dataType.ToUpper()
166+
let dataType = dataType.ToUpperInvariant()
167167
match typeMappingsByName.TryFind dataType with
168168
| Some tm -> tm
169169
| None ->

src/SQLProvider.Runtime/Providers.MsSqlServer.fs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -258,7 +258,7 @@ module MSSqlServer =
258258
not <| Set.contains name toFilter)
259259
|> DataTable.map (fun row -> getSprocName row, dbUnbox<string> row.["routine_type"])
260260
|> Seq.map (fun (name, routineType) ->
261-
match routineType.ToUpper() with
261+
match routineType.ToUpperInvariant() with
262262
| "FUNCTION" -> Root("Functions", Sproc({ Name = name; Params = (fun con -> getSprocParameters con name); ReturnColumns = (fun con sparams -> getSprocReturnCols con name sparams) }))
263263
| "PROCEDURE" -> Root("Procedures", Sproc({ Name = name; Params = (fun con -> getSprocParameters con name); ReturnColumns = (fun con sparams -> getSprocReturnCols con name sparams) }))
264264
| _ -> Empty

src/SQLProvider.Runtime/Providers.MySql.fs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -302,7 +302,7 @@ module MySql =
302302
getSchema "Procedures" [||] con
303303
|> DataTable.map (fun row ->
304304
let name = getSprocName row
305-
match (Sql.dbUnbox<string> row.["routine_type"]).ToUpper() with
305+
match (Sql.dbUnbox<string> row.["routine_type"]).ToUpperInvariant() with
306306
| "FUNCTION" -> Root("Functions", Sproc({ Name = name; Params = (fun con -> getSprocParameters con name); ReturnColumns = (fun _ name -> getSprocReturnCols name) }))
307307
| "PROCEDURE" -> Root("Procedures", Sproc({ Name = name; Params = (fun con -> getSprocParameters con name); ReturnColumns = (fun _ name -> getSprocReturnCols name) }))
308308
| _ -> Empty
@@ -633,7 +633,7 @@ type internal MySqlProvider(resolutionPath, contextSchemaPath, owner:string, ref
633633
let maxlen =
634634
if reader.IsDBNull(2) then ""
635635
else reader.GetValue(2).ToString()
636-
let isUnsigned = not(reader.IsDBNull 6) && reader.GetString(6).ToUpper().Contains("UNSIGNED")
636+
let isUnsigned = not(reader.IsDBNull 6) && reader.GetString(6).ToUpperInvariant().Contains("UNSIGNED")
637637
let udt = if isUnsigned then dt + " unsigned" else dt
638638
match MySql.findDbType udt with
639639
| Some(m) ->

0 commit comments

Comments
 (0)