Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

exploration into Npgsql command rewrite #84

Open
wants to merge 22 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 5 additions & 4 deletions Directory.Packages.props
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,14 @@
<PackageVersion Include="BenchmarkDotNet" Version="0.13.10" />
<PackageVersion Include="FastMember" Version="1.5.0" />
<PackageVersion Include="Dapper" Version="2.1.21" />
<PackageVersion Include="Dapper.AOT" Version="1.0.14" />
<PackageVersion Include="Dapper.AOT" Version="1.0.23" />
<PackageVersion Include="Dapper.Advisor" Version="1.0.23" />
<PackageVersion Include="Dapper.StrongName" Version="2.1.21" />
<PackageVersion Include="Nerdbank.GitVersioning" Version="3.6.133" />
<PackageVersion Include="Npgsql" Version="7.0.6" />
<PackageVersion Include="Microsoft.Bcl.AsyncInterfaces" Version="8.0.0" />
<PackageVersion Include="Microsoft.Build" Version="17.7.2" />
<PackageVersion Include="Microsoft.Build.Utilities.Core" Version="17.7.2" />
<PackageVersion Include="Microsoft.Build" Version="17.8.3" />
<PackageVersion Include="Microsoft.Build.Utilities.Core" Version="17.8.3" />
<PackageVersion Include="Microsoft.CodeAnalysis.CSharp.Analyzer.Testing.XUnit" Version="1.1.1" />
<PackageVersion Include="Microsoft.CodeAnalysis.CSharp.CodeFix.Testing.XUnit" Version="1.1.1" />
<!-- 4.8 would be nice, but: let's try to offer down-level compiler support -->
Expand All @@ -23,7 +24,7 @@
<PackageVersion Include="Microsoft.EntityFrameworkCore" Version="8.0.0" />
<PackageVersion Include="Microsoft.EntityFrameworkCore.SqlServer" Version="8.0.0" />
<PackageVersion Include="Microsoft.NET.Test.Sdk" Version="17.8.0" />
<PackageVersion Include="Microsoft.SourceLink.GitHub" Version="1.1.1" />
<PackageVersion Include="Microsoft.SourceLink.GitHub" Version="8.0.0" />
<PackageVersion Include="Microsoft.SqlServer.TransactSql.ScriptDom" Version="161.8910.0" />
<PackageVersion Include="Oracle.ManagedDataAccess" Version="21.12.0" />
<PackageVersion Include="Oracle.ManagedDataAccess.Core" Version="3.21.120" />
Expand Down
24 changes: 24 additions & 0 deletions docs/rules/DAP245.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
# DAP245

It is possible for an identifier to be *technically valid* to use without quoting, yet highly confusing As an example, the following TSQL is *entirely valid*:

``` sql
CREATE TABLE GO (GO int not null)
GO
INSERT GO ( GO ) VALUES (42)
GO
SELECT GO FROM GO
```

However, this can confuse readers and parsing tools. It would be *hugely*
advantageous to use delimited identifiers appropriately:

``` sql
CREATE TABLE [GO] ([GO] int not null)
GO
INSERT [GO] ( [GO] ) VALUES (42)
GO
SELECT [GO] FROM [GO]
```

Or... maybe just use a different name?
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,7 @@ public static readonly DiagnosticDescriptor
InterpolatedStringSqlExpression = SqlWarning("DAP241", "Interpolated string usage", "Data values should not be interpolated into SQL string - use parameters instead"),
ConcatenatedStringSqlExpression = SqlWarning("DAP242", "Concatenated string usage", "Data values should not be concatenated into SQL string - use parameters instead"),
InvalidDatepartToken = SqlWarning("DAP243", "Valid datepart token expected", "Date functions require a recognized datepart argument"),
SelectAggregateMismatch = SqlWarning("DAP244", "SELECT aggregate mismatch", "SELECT has mixture of aggregate and non-aggregate expressions");
SelectAggregateMismatch = SqlWarning("DAP244", "SELECT aggregate mismatch", "SELECT has mixture of aggregate and non-aggregate expressions"),
DangerousNonDelimitedIdentifier = SqlWarning("DAP245", "Dangerous non-delimited identifier", "The identifier '{0}' can be confusing when not delimited; consider delimiting it with [...]");
}
}
3 changes: 3 additions & 0 deletions src/Dapper.AOT.Analyzers/Internal/DiagnosticTSqlProcessor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -161,4 +161,7 @@ protected override void OnInvalidNullExpression(Location location)

protected override void OnTrivialOperand(Location location)
=> OnDiagnostic(DapperAnalyzer.Diagnostics.TrivialOperand, location);

protected override void OnDangerousNonDelimitedIdentifier(Location location, string name)
=> OnDiagnostic(DapperAnalyzer.Diagnostics.DangerousNonDelimitedIdentifier, location, name);
}
Loading
Loading