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

[DAP226] False positive: DATEADD #80

Closed
dotTrench opened this issue Nov 16, 2023 · 2 comments · Fixed by #82
Closed

[DAP226] False positive: DATEADD #80

dotTrench opened this issue Nov 16, 2023 · 2 comments · Fixed by #82

Comments

@dotTrench
Copy link

Describe the bug
When using SqlConnection and querying data using the built-in MSSQL-function DATEADD parameter datepart is falsely identified as a table column causing a false DAP226 warning when used in a query with joins.

Dapper.Advisor: 1.0.10

To Reproduce

// DAP226: FROM expressions with multiple elements should qualify all columns; it is unclear where 'YEAR' is located
public static async Task DateAddWithJoin(SqlConnection connection) =>
    await connection.QueryAsync(
        """
        SELECT DATEADD(YEAR, 1, t.Year) AS NextYear
        FROM MyTable t
        JOIN MyOtherTable o ON o.Id = t.Id
        """
    );
@mgravell
Copy link
Member

mgravell commented Nov 16, 2023

Fair. Should be a very simple fix! Will look tomorrow

mgravell added a commit that referenced this issue Nov 17, 2023
* fix #79

* fix #80; add new rule 243 for invalid datepart expressions

* groundwork for aggregate

* fix #81; add new rule DAP244 for mixing aggregate and non-aggregate data
@mgravell
Copy link
Member

https://github.com/DapperLib/DapperAOT/releases/tag/1.0.16

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants