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

Wrong parameter names can be generated for raw SQL strings #78

Closed
esentio opened this issue Nov 20, 2020 · 0 comments · Fixed by #80
Closed

Wrong parameter names can be generated for raw SQL strings #78

esentio opened this issue Nov 20, 2020 · 0 comments · Fixed by #80
Labels
bug Something isn't working

Comments

@esentio
Copy link
Owner

esentio commented Nov 20, 2020

Using ColumnsModelInfo, ColumnModelInfo, TableModelInfo or RawSqlString object in raw SQL string increments local (scoped to that raw SQL string) parameter name index counter, although no parameter is generated. If it is followed by another local parameter, that parameter will have name, that will collide with potential parameters added later in different clauses.

For example:

Dim result = db.From(Of Article).
                Join(Of Label)($"(SELECT {Sql.Model.Columns(Of Label)} FROM LabelArchive WHERE Language = {lang})").
                On(Function(a, l) a.Id = l.Id).
                Where(Function(a, l) a.Price <= maxPrice).
                SelectAll().ToList()
' lang -> @p1, but should be @p0
' maxPrice -> @p1
@esentio esentio added the bug Something isn't working label Nov 20, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant