Skip to content

Commit 66b6496

Browse files
authored
Merge pull request #862 from fsprojects/copilot/refactor-to-upper-invariant
Change .ToUpper() to .ToUpperInvariant() for culture-independent string comparisons
2 parents c7e97d2 + 32f014e commit 66b6496

10 files changed

Lines changed: 19 additions & 24 deletions

File tree

.paket/Paket.Restore.targets

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -235,15 +235,14 @@
235235
<Splits>$([System.String]::Copy('%(PaketReferencesFileLines.Identity)').Split(',').Length)</Splits>
236236
<PackageName>$([System.String]::Copy('%(PaketReferencesFileLines.Identity)').Split(',')[0])</PackageName>
237237
<PackageVersion>$([System.String]::Copy('%(PaketReferencesFileLines.Identity)').Split(',')[1])</PackageVersion>
238-
<Reference>$([System.String]::Copy('%(PaketReferencesFileLines.Identity)').Split(',')[2])</Reference>
239238
<AllPrivateAssets>$([System.String]::Copy('%(PaketReferencesFileLines.Identity)').Split(',')[4])</AllPrivateAssets>
240239
<CopyLocal Condition="%(PaketReferencesFileLinesInfo.Splits) &gt;= 6">$([System.String]::Copy('%(PaketReferencesFileLines.Identity)').Split(',')[5])</CopyLocal>
241240
<OmitContent Condition="%(PaketReferencesFileLinesInfo.Splits) &gt;= 7">$([System.String]::Copy('%(PaketReferencesFileLines.Identity)').Split(',')[6])</OmitContent>
242241
<ImportTargets Condition="%(PaketReferencesFileLinesInfo.Splits) &gt;= 8">$([System.String]::Copy('%(PaketReferencesFileLines.Identity)').Split(',')[7])</ImportTargets>
243242
<Aliases Condition="%(PaketReferencesFileLinesInfo.Splits) &gt;= 9">$([System.String]::Copy('%(PaketReferencesFileLines.Identity)').Split(',')[8])</Aliases>
244243
</PaketReferencesFileLinesInfo>
245-
<PackageReference Condition=" '$(ManagePackageVersionsCentrally)' != 'true' Or '%(PaketReferencesFileLinesInfo.Reference)' == 'Direct' " Include="%(PaketReferencesFileLinesInfo.PackageName)">
246-
<Version Condition=" '$(ManagePackageVersionsCentrally)' != 'true' ">%(PaketReferencesFileLinesInfo.PackageVersion)</Version>
244+
<PackageReference Include="%(PaketReferencesFileLinesInfo.PackageName)">
245+
<Version>%(PaketReferencesFileLinesInfo.PackageVersion)</Version>
247246
<PrivateAssets Condition=" ('%(PaketReferencesFileLinesInfo.AllPrivateAssets)' == 'true') Or ('$(PackAsTool)' == 'true') ">All</PrivateAssets>
248247
<ExcludeAssets Condition=" %(PaketReferencesFileLinesInfo.CopyLocal) == 'false' or %(PaketReferencesFileLinesInfo.AllPrivateAssets) == 'exclude'">runtime</ExcludeAssets>
249248
<ExcludeAssets Condition=" %(PaketReferencesFileLinesInfo.OmitContent) == 'true'">$(ExcludeAssets);contentFiles</ExcludeAssets>
@@ -253,10 +252,6 @@
253252
<AllowExplicitVersion>true</AllowExplicitVersion>
254253

255254
</PackageReference>
256-
257-
<PackageVersion Include="%(PaketReferencesFileLinesInfo.PackageName)">
258-
<Version>%(PaketReferencesFileLinesInfo.PackageVersion)</Version>
259-
</PackageVersion>
260255
</ItemGroup>
261256

262257
<PropertyGroup>

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
@@ -326,7 +326,7 @@ module MSSqlServerDynamic =
326326
not <| Set.contains name toFilter)
327327
|> DataTable.map (fun row -> getSprocName row, dbUnbox<string> row.["routine_type"])
328328
|> Seq.map (fun (name, routineType) ->
329-
match routineType.ToUpper() with
329+
match routineType.ToUpperInvariant() with
330330
| "FUNCTION" -> Root("Functions", Sproc({ Name = name; Params = (fun con -> getSprocParameters con name); ReturnColumns = (fun con sparams -> getSprocReturnCols con name sparams) }))
331331
| "PROCEDURE" -> Root("Procedures", Sproc({ Name = name; Params = (fun con -> getSprocParameters con name); ReturnColumns = (fun con sparams -> getSprocReturnCols con name sparams) }))
332332
| _ -> 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
@@ -253,7 +253,7 @@ module MSSqlServer =
253253
not <| Set.contains name toFilter)
254254
|> DataTable.map (fun row -> getSprocName row, dbUnbox<string> row.["routine_type"])
255255
|> Seq.map (fun (name, routineType) ->
256-
match routineType.ToUpper() with
256+
match routineType.ToUpperInvariant() with
257257
| "FUNCTION" -> Root("Functions", Sproc({ Name = name; Params = (fun con -> getSprocParameters con name); ReturnColumns = (fun con sparams -> getSprocReturnCols con name sparams) }))
258258
| "PROCEDURE" -> Root("Procedures", Sproc({ Name = name; Params = (fun con -> getSprocParameters con name); ReturnColumns = (fun con sparams -> getSprocReturnCols con name sparams) }))
259259
| _ -> 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)