Skip to content

Commit

Permalink
Npgsql.FSharp.Analyzer v3.24.0 fixes #27 and other problems with resp…
Browse files Browse the repository at this point in the history
…ect to dynamically applied parameters
  • Loading branch information
Zaid-Ajaj committed Apr 8, 2021
1 parent 025b5de commit 9f75658
Show file tree
Hide file tree
Showing 27 changed files with 199 additions and 106 deletions.
3 changes: 3 additions & 0 deletions RELEASE_NOTES.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
### 3.24.0 - 2021-04-09
* fixes dynamically applied parameters with more complex expressions

### 3.23.0 - 2021-03-26
* Detect typed let bindings

Expand Down
20 changes: 10 additions & 10 deletions src/FParsec/AssemblyInfo.fs
Original file line number Diff line number Diff line change
Expand Up @@ -4,20 +4,20 @@ open System.Reflection

[<assembly: AssemblyTitleAttribute("FParsec")>]
[<assembly: AssemblyProductAttribute("NpgsqlFSharpAnalyzer")>]
[<assembly: AssemblyVersionAttribute("3.23.0")>]
[<assembly: AssemblyMetadataAttribute("ReleaseDate","2021-03-26T00:00:00.0000000")>]
[<assembly: AssemblyFileVersionAttribute("3.23.0")>]
[<assembly: AssemblyInformationalVersionAttribute("3.23.0")>]
[<assembly: AssemblyVersionAttribute("3.24.0")>]
[<assembly: AssemblyMetadataAttribute("ReleaseDate","2021-04-09T00:00:00.0000000")>]
[<assembly: AssemblyFileVersionAttribute("3.24.0")>]
[<assembly: AssemblyInformationalVersionAttribute("3.24.0")>]
[<assembly: AssemblyMetadataAttribute("ReleaseChannel","release")>]
[<assembly: AssemblyMetadataAttribute("GitHash","bc8bff18abbd6b4cfd14b67738c9ec22a5412c90")>]
[<assembly: AssemblyMetadataAttribute("GitHash","025b5de26ae76e867d47a4047d85d2ab5683940b")>]
do ()

module internal AssemblyVersionInformation =
let [<Literal>] AssemblyTitle = "FParsec"
let [<Literal>] AssemblyProduct = "NpgsqlFSharpAnalyzer"
let [<Literal>] AssemblyVersion = "3.23.0"
let [<Literal>] AssemblyMetadata_ReleaseDate = "2021-03-26T00:00:00.0000000"
let [<Literal>] AssemblyFileVersion = "3.23.0"
let [<Literal>] AssemblyInformationalVersion = "3.23.0"
let [<Literal>] AssemblyVersion = "3.24.0"
let [<Literal>] AssemblyMetadata_ReleaseDate = "2021-04-09T00:00:00.0000000"
let [<Literal>] AssemblyFileVersion = "3.24.0"
let [<Literal>] AssemblyInformationalVersion = "3.24.0"
let [<Literal>] AssemblyMetadata_ReleaseChannel = "release"
let [<Literal>] AssemblyMetadata_GitHash = "bc8bff18abbd6b4cfd14b67738c9ec22a5412c90"
let [<Literal>] AssemblyMetadata_GitHash = "025b5de26ae76e867d47a4047d85d2ab5683940b"
20 changes: 10 additions & 10 deletions src/NpgsqlFSharpAnalyzer.Core/AssemblyInfo.fs
Original file line number Diff line number Diff line change
Expand Up @@ -4,20 +4,20 @@ open System.Reflection

[<assembly: AssemblyTitleAttribute("NpgsqlFSharpAnalyzer.Core")>]
[<assembly: AssemblyProductAttribute("NpgsqlFSharpAnalyzer")>]
[<assembly: AssemblyVersionAttribute("3.23.0")>]
[<assembly: AssemblyMetadataAttribute("ReleaseDate","2021-03-26T00:00:00.0000000")>]
[<assembly: AssemblyFileVersionAttribute("3.23.0")>]
[<assembly: AssemblyInformationalVersionAttribute("3.23.0")>]
[<assembly: AssemblyVersionAttribute("3.24.0")>]
[<assembly: AssemblyMetadataAttribute("ReleaseDate","2021-04-09T00:00:00.0000000")>]
[<assembly: AssemblyFileVersionAttribute("3.24.0")>]
[<assembly: AssemblyInformationalVersionAttribute("3.24.0")>]
[<assembly: AssemblyMetadataAttribute("ReleaseChannel","release")>]
[<assembly: AssemblyMetadataAttribute("GitHash","bc8bff18abbd6b4cfd14b67738c9ec22a5412c90")>]
[<assembly: AssemblyMetadataAttribute("GitHash","025b5de26ae76e867d47a4047d85d2ab5683940b")>]
do ()

module internal AssemblyVersionInformation =
let [<Literal>] AssemblyTitle = "NpgsqlFSharpAnalyzer.Core"
let [<Literal>] AssemblyProduct = "NpgsqlFSharpAnalyzer"
let [<Literal>] AssemblyVersion = "3.23.0"
let [<Literal>] AssemblyMetadata_ReleaseDate = "2021-03-26T00:00:00.0000000"
let [<Literal>] AssemblyFileVersion = "3.23.0"
let [<Literal>] AssemblyInformationalVersion = "3.23.0"
let [<Literal>] AssemblyVersion = "3.24.0"
let [<Literal>] AssemblyMetadata_ReleaseDate = "2021-04-09T00:00:00.0000000"
let [<Literal>] AssemblyFileVersion = "3.24.0"
let [<Literal>] AssemblyInformationalVersion = "3.24.0"
let [<Literal>] AssemblyMetadata_ReleaseChannel = "release"
let [<Literal>] AssemblyMetadata_GitHash = "bc8bff18abbd6b4cfd14b67738c9ec22a5412c90"
let [<Literal>] AssemblyMetadata_GitHash = "025b5de26ae76e867d47a4047d85d2ab5683940b"
49 changes: 40 additions & 9 deletions src/NpgsqlFSharpAnalyzer.Core/SyntacticAnalysis.fs
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,8 @@ module SyntacticAnalysis =
let (|ParameterTuple|_|) = function
| SynExpr.Tuple(isStruct, [ SynExpr.Const(SynConst.String(parameterName, paramRange), constRange); Apply(funcName, exprArgs, funcRange, appRange) ], commaRange, tupleRange) ->
Some (parameterName, paramRange, funcName, funcRange, Some appRange)
| SynExpr.Tuple(isStruct, [ SynExpr.Const(SynConst.String(parameterName, paramRange), constRange); SynExpr.Paren(Apply(funcName, exprArgs, funcRange, appRange), leftParenRange, rightParenRange, _) ], commaRange, tupleRange) ->
Some (parameterName, paramRange, funcName, funcRange, Some appRange)
| SynExpr.Tuple(isStruct, [ SynExpr.Const(SynConst.String(parameterName, paramRange), constRange); secondItem ], commaRange, tupleRange) ->
match secondItem with
| SynExpr.LongIdent(isOptional, longDotId, altName, identRange) ->
Expand All @@ -65,16 +67,36 @@ module SyntacticAnalysis =
|> String.concat "."

Some (parameterName, paramRange, fullName, identRange, None)
| _ ->
| Apply(funcName, innerArg, funcRange, appRange) ->
Some (parameterName, paramRange, funcName, funcRange, None)

| SynExpr.App(flag, inFix, funcExpr, argExpr, fullAppRange) ->
match argExpr with
| SynExpr.LongIdent(isOptional, longDotId, altName, identRange) ->
match longDotId with
| LongIdentWithDots(listOfIds, ranges) ->
let fullName =
listOfIds
|> List.map (fun id -> id.idText)
|> String.concat "."

Some (parameterName, paramRange, fullName, identRange, None)
| Apply(funcName, innerArg, funcRange, appRange) ->
Some (parameterName, paramRange, funcName, funcRange, None)
| otherwise ->
None
| otherwise ->
None
| _ ->
| otherwise ->
None

let rec readParameters = function
| ParameterTuple (name, range, func, funcRange, appRange) ->
[ name, range, func, funcRange, appRange ]
| SynExpr.Sequential(_debugSeqPoint, isTrueSeq, expr1, expr2, seqRange) ->
[ yield! readParameters expr1; yield! readParameters expr2 ]
| SynExpr.Paren(ParameterTuple (name, range, func, funcRange, appRange), _, _, _) ->
[ name, range, func, funcRange, appRange ]
| _ ->
[ ]

Expand All @@ -89,9 +111,9 @@ module SyntacticAnalysis =
match listExpr with
| SynExpr.CompExpr(isArrayOfList, isNotNakedRefCell, compExpr, compRange) ->
Some (readParameters compExpr, compRange)
| _ ->
| otherwise ->
None
| _ ->
| otherwise ->
None

let readParameterSets parameterSetsExpr =
Expand Down Expand Up @@ -125,7 +147,7 @@ module SyntacticAnalysis =
range = range
applicationRange = appRange
}
| _ ->
| otherwise ->
()
]

Expand All @@ -146,7 +168,7 @@ module SyntacticAnalysis =
range = range
applicationRange = appRange
}
| _ ->
| otherwise ->
()
]

Expand Down Expand Up @@ -240,7 +262,7 @@ module SyntacticAnalysis =
}

Some transaction
| _ ->
| otherwise ->
None

let rec readTransactionQueries = function
Expand All @@ -261,7 +283,13 @@ module SyntacticAnalysis =
Some (readTransactionQueries compExpr)
| _ ->
None
| _ ->
| Apply (("Sql.executeTransaction"|"Sql.executeTransactionAsync"), SynExpr.ArrayOrList(isList, listExpr, range), funcRange, appRange) ->
let expressions =
listExpr
|> List.collect readTransactionQueries

Some expressions
| otherwise ->
None

let (|ReadColumnAttempt|_|) = function
Expand Down Expand Up @@ -382,7 +410,7 @@ module SyntacticAnalysis =
| SynExpr.App(exprAtomic, isInfix, funcExpr, argExpr, range) ->
[ yield! findParameters funcExpr; yield! findParameters argExpr ]

| _ ->
| otherwise ->
[ ]

let rec findExecuteTransaction = function
Expand Down Expand Up @@ -592,6 +620,7 @@ module SyntacticAnalysis =
yield! findQuery funcExpr
yield! findParameters funcExpr
yield! findSkipAnalysis funcExpr
yield! findExecuteTransaction funcExpr
]

[ { blocks = blocks; range = range; } ]
Expand All @@ -601,6 +630,7 @@ module SyntacticAnalysis =
yield! findFunc funcExpr
yield! findQuery funcExpr
yield! findParameters funcExpr
yield! findExecuteTransaction funcExpr
yield SqlAnalyzerBlock.SkipAnalysis
yield SqlAnalyzerBlock.ReadingColumns (findReadColumnAttempts funcExpr)
]
Expand All @@ -613,6 +643,7 @@ module SyntacticAnalysis =
yield! findQuery funcExpr
yield! findParameters funcExpr
yield! findSkipAnalysis funcExpr
yield! findExecuteTransaction funcExpr
yield SqlAnalyzerBlock.ReadingColumns (findReadColumnAttempts funcExpr)
]

Expand Down
20 changes: 10 additions & 10 deletions src/NpgsqlFSharpAnalyzer/AssemblyInfo.fs
Original file line number Diff line number Diff line change
Expand Up @@ -4,20 +4,20 @@ open System.Reflection

[<assembly: AssemblyTitleAttribute("NpgsqlFSharpAnalyzer")>]
[<assembly: AssemblyProductAttribute("NpgsqlFSharpAnalyzer")>]
[<assembly: AssemblyVersionAttribute("3.23.0")>]
[<assembly: AssemblyMetadataAttribute("ReleaseDate","2021-03-26T00:00:00.0000000")>]
[<assembly: AssemblyFileVersionAttribute("3.23.0")>]
[<assembly: AssemblyInformationalVersionAttribute("3.23.0")>]
[<assembly: AssemblyVersionAttribute("3.24.0")>]
[<assembly: AssemblyMetadataAttribute("ReleaseDate","2021-04-09T00:00:00.0000000")>]
[<assembly: AssemblyFileVersionAttribute("3.24.0")>]
[<assembly: AssemblyInformationalVersionAttribute("3.24.0")>]
[<assembly: AssemblyMetadataAttribute("ReleaseChannel","release")>]
[<assembly: AssemblyMetadataAttribute("GitHash","bc8bff18abbd6b4cfd14b67738c9ec22a5412c90")>]
[<assembly: AssemblyMetadataAttribute("GitHash","025b5de26ae76e867d47a4047d85d2ab5683940b")>]
do ()

module internal AssemblyVersionInformation =
let [<Literal>] AssemblyTitle = "NpgsqlFSharpAnalyzer"
let [<Literal>] AssemblyProduct = "NpgsqlFSharpAnalyzer"
let [<Literal>] AssemblyVersion = "3.23.0"
let [<Literal>] AssemblyMetadata_ReleaseDate = "2021-03-26T00:00:00.0000000"
let [<Literal>] AssemblyFileVersion = "3.23.0"
let [<Literal>] AssemblyInformationalVersion = "3.23.0"
let [<Literal>] AssemblyVersion = "3.24.0"
let [<Literal>] AssemblyMetadata_ReleaseDate = "2021-04-09T00:00:00.0000000"
let [<Literal>] AssemblyFileVersion = "3.24.0"
let [<Literal>] AssemblyInformationalVersion = "3.24.0"
let [<Literal>] AssemblyMetadata_ReleaseChannel = "release"
let [<Literal>] AssemblyMetadata_GitHash = "bc8bff18abbd6b4cfd14b67738c9ec22a5412c90"
let [<Literal>] AssemblyMetadata_GitHash = "025b5de26ae76e867d47a4047d85d2ab5683940b"
20 changes: 10 additions & 10 deletions src/NpgsqlFSharpParser/AssemblyInfo.fs
Original file line number Diff line number Diff line change
Expand Up @@ -4,20 +4,20 @@ open System.Reflection

[<assembly: AssemblyTitleAttribute("NpgsqlFSharpParser")>]
[<assembly: AssemblyProductAttribute("NpgsqlFSharpAnalyzer")>]
[<assembly: AssemblyVersionAttribute("3.23.0")>]
[<assembly: AssemblyMetadataAttribute("ReleaseDate","2021-03-26T00:00:00.0000000")>]
[<assembly: AssemblyFileVersionAttribute("3.23.0")>]
[<assembly: AssemblyInformationalVersionAttribute("3.23.0")>]
[<assembly: AssemblyVersionAttribute("3.24.0")>]
[<assembly: AssemblyMetadataAttribute("ReleaseDate","2021-04-09T00:00:00.0000000")>]
[<assembly: AssemblyFileVersionAttribute("3.24.0")>]
[<assembly: AssemblyInformationalVersionAttribute("3.24.0")>]
[<assembly: AssemblyMetadataAttribute("ReleaseChannel","release")>]
[<assembly: AssemblyMetadataAttribute("GitHash","bc8bff18abbd6b4cfd14b67738c9ec22a5412c90")>]
[<assembly: AssemblyMetadataAttribute("GitHash","025b5de26ae76e867d47a4047d85d2ab5683940b")>]
do ()

module internal AssemblyVersionInformation =
let [<Literal>] AssemblyTitle = "NpgsqlFSharpParser"
let [<Literal>] AssemblyProduct = "NpgsqlFSharpAnalyzer"
let [<Literal>] AssemblyVersion = "3.23.0"
let [<Literal>] AssemblyMetadata_ReleaseDate = "2021-03-26T00:00:00.0000000"
let [<Literal>] AssemblyFileVersion = "3.23.0"
let [<Literal>] AssemblyInformationalVersion = "3.23.0"
let [<Literal>] AssemblyVersion = "3.24.0"
let [<Literal>] AssemblyMetadata_ReleaseDate = "2021-04-09T00:00:00.0000000"
let [<Literal>] AssemblyFileVersion = "3.24.0"
let [<Literal>] AssemblyInformationalVersion = "3.24.0"
let [<Literal>] AssemblyMetadata_ReleaseChannel = "release"
let [<Literal>] AssemblyMetadata_GitHash = "bc8bff18abbd6b4cfd14b67738c9ec22a5412c90"
let [<Literal>] AssemblyMetadata_GitHash = "025b5de26ae76e867d47a4047d85d2ab5683940b"
2 changes: 1 addition & 1 deletion src/NpgsqlFSharpVs/source.extension.vsixmanifest
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
xmlns="http://schemas.microsoft.com/developer/vsx-schema/2011"
xmlns:d="http://schemas.microsoft.com/developer/vsx-schema-design/2011">
<Metadata>
<Identity Id="FSharpLintVs.ef00bfc3-a899-45fc-aae8-afecf8673aaf" Version="3.23.0" Language="en-US" Publisher="Zaid Ajaj" />
<Identity Id="FSharpLintVs.ef00bfc3-a899-45fc-aae8-afecf8673aaf" Version="3.24.0" Language="en-US" Publisher="Zaid Ajaj" />
<DisplayName>NpgsqlFSharpVs</DisplayName>
<Description xml:space="preserve">F# Analyzer for embedded SQL syntax analysis, type-checking for parameters and result sets and nullable column detection when writing queries using Npgsql.FSharp.</Description>
<MoreInfo>https://github.com/Zaid-Ajaj/Npgsql.FSharp.Analyzer</MoreInfo>
Expand Down
20 changes: 10 additions & 10 deletions src/Ubik/AssemblyInfo.fs
Original file line number Diff line number Diff line change
Expand Up @@ -4,20 +4,20 @@ open System.Reflection

[<assembly: AssemblyTitleAttribute("Ubik")>]
[<assembly: AssemblyProductAttribute("NpgsqlFSharpAnalyzer")>]
[<assembly: AssemblyVersionAttribute("3.23.0")>]
[<assembly: AssemblyMetadataAttribute("ReleaseDate","2021-03-26T00:00:00.0000000")>]
[<assembly: AssemblyFileVersionAttribute("3.23.0")>]
[<assembly: AssemblyInformationalVersionAttribute("3.23.0")>]
[<assembly: AssemblyVersionAttribute("3.24.0")>]
[<assembly: AssemblyMetadataAttribute("ReleaseDate","2021-04-09T00:00:00.0000000")>]
[<assembly: AssemblyFileVersionAttribute("3.24.0")>]
[<assembly: AssemblyInformationalVersionAttribute("3.24.0")>]
[<assembly: AssemblyMetadataAttribute("ReleaseChannel","release")>]
[<assembly: AssemblyMetadataAttribute("GitHash","bc8bff18abbd6b4cfd14b67738c9ec22a5412c90")>]
[<assembly: AssemblyMetadataAttribute("GitHash","025b5de26ae76e867d47a4047d85d2ab5683940b")>]
do ()

module internal AssemblyVersionInformation =
let [<Literal>] AssemblyTitle = "Ubik"
let [<Literal>] AssemblyProduct = "NpgsqlFSharpAnalyzer"
let [<Literal>] AssemblyVersion = "3.23.0"
let [<Literal>] AssemblyMetadata_ReleaseDate = "2021-03-26T00:00:00.0000000"
let [<Literal>] AssemblyFileVersion = "3.23.0"
let [<Literal>] AssemblyInformationalVersion = "3.23.0"
let [<Literal>] AssemblyVersion = "3.24.0"
let [<Literal>] AssemblyMetadata_ReleaseDate = "2021-04-09T00:00:00.0000000"
let [<Literal>] AssemblyFileVersion = "3.24.0"
let [<Literal>] AssemblyInformationalVersion = "3.24.0"
let [<Literal>] AssemblyMetadata_ReleaseChannel = "release"
let [<Literal>] AssemblyMetadata_GitHash = "bc8bff18abbd6b4cfd14b67738c9ec22a5412c90"
let [<Literal>] AssemblyMetadata_GitHash = "025b5de26ae76e867d47a4047d85d2ab5683940b"
4 changes: 2 additions & 2 deletions src/Ubik/Ubik.fsproj
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@
<PackAsTool>true</PackAsTool>
<IsPackable>true</IsPackable>
<RollForward>Major</RollForward>
<Version>3.23.0</Version>
<PackageReleaseNotes>Detect typed let bindings</PackageReleaseNotes>
<Version>3.24.0</Version>
<PackageReleaseNotes>Fixes complex applied expressions to the </PackageReleaseNotes>
</PropertyGroup>

<ItemGroup>
Expand Down
20 changes: 10 additions & 10 deletions tests/NpgsqlFSharpAnalyzer.Tests/AssemblyInfo.fs
Original file line number Diff line number Diff line change
Expand Up @@ -4,20 +4,20 @@ open System.Reflection

[<assembly: AssemblyTitleAttribute("NpgsqlFSharpAnalyzer.Tests")>]
[<assembly: AssemblyProductAttribute("NpgsqlFSharpAnalyzer")>]
[<assembly: AssemblyVersionAttribute("3.23.0")>]
[<assembly: AssemblyMetadataAttribute("ReleaseDate","2021-03-26T00:00:00.0000000")>]
[<assembly: AssemblyFileVersionAttribute("3.23.0")>]
[<assembly: AssemblyInformationalVersionAttribute("3.23.0")>]
[<assembly: AssemblyVersionAttribute("3.24.0")>]
[<assembly: AssemblyMetadataAttribute("ReleaseDate","2021-04-09T00:00:00.0000000")>]
[<assembly: AssemblyFileVersionAttribute("3.24.0")>]
[<assembly: AssemblyInformationalVersionAttribute("3.24.0")>]
[<assembly: AssemblyMetadataAttribute("ReleaseChannel","release")>]
[<assembly: AssemblyMetadataAttribute("GitHash","bc8bff18abbd6b4cfd14b67738c9ec22a5412c90")>]
[<assembly: AssemblyMetadataAttribute("GitHash","025b5de26ae76e867d47a4047d85d2ab5683940b")>]
do ()

module internal AssemblyVersionInformation =
let [<Literal>] AssemblyTitle = "NpgsqlFSharpAnalyzer.Tests"
let [<Literal>] AssemblyProduct = "NpgsqlFSharpAnalyzer"
let [<Literal>] AssemblyVersion = "3.23.0"
let [<Literal>] AssemblyMetadata_ReleaseDate = "2021-03-26T00:00:00.0000000"
let [<Literal>] AssemblyFileVersion = "3.23.0"
let [<Literal>] AssemblyInformationalVersion = "3.23.0"
let [<Literal>] AssemblyVersion = "3.24.0"
let [<Literal>] AssemblyMetadata_ReleaseDate = "2021-04-09T00:00:00.0000000"
let [<Literal>] AssemblyFileVersion = "3.24.0"
let [<Literal>] AssemblyInformationalVersion = "3.24.0"
let [<Literal>] AssemblyMetadata_ReleaseChannel = "release"
let [<Literal>] AssemblyMetadata_GitHash = "bc8bff18abbd6b4cfd14b67738c9ec22a5412c90"
let [<Literal>] AssemblyMetadata_GitHash = "025b5de26ae76e867d47a4047d85d2ab5683940b"
22 changes: 21 additions & 1 deletion tests/NpgsqlFSharpAnalyzer.Tests/Tests.fs
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ let tests =
| None -> failwith "Could not crack project"
| Some context ->
let operationBlocks = SyntacticAnalysis.findSqlOperations context
Expect.equal (List.length operationBlocks) 12 "Found 12 operation blocks"
Expect.equal (List.length operationBlocks) 15 "Found 15 operation blocks"
}

test "Syntactic analysis: no SQL blocks should be found using sprintf" {
Expand All @@ -49,6 +49,26 @@ let tests =
Expect.isEmpty operations "There should be no syntactic blocks"
}

test "Syntactic Analysis: finding processed parameters" {
match context (find "../examples/hashing/usingProcessedParameters.fs") with
| None -> failwith "Could not crack project"
| Some context ->
let operationBlocks = SyntacticAnalysis.findSqlOperations context
Expect.equal (List.length operationBlocks) 1 "Found 1 operation"
let parameters =
[
for operation in operationBlocks do
for block in operation.blocks do
match block with
| SqlAnalyzerBlock.Parameters (parameters, _) ->
yield! parameters
| _ ->
()
]

Expect.equal 2 parameters.Length "There are 2 parameters"
}

test "Syntactic analysis: SQL block found from top-level expression in module" {
match context (find "../examples/hashing/topLevelExpressionIsDetected.fs") with
| None -> failwith "Could not crack project"
Expand Down
Loading

0 comments on commit 9f75658

Please sign in to comment.