You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Describe the bug
SQL Server requires SELECT TOP (@p1) ... when generating a parameterized statement (parentheses around the parameter, only for TOP). This library generates SELECT TOP @p1 ... which results in an error: mssql: Incorrect syntax near '@p1'
To Reproduce
I wrote the following (a copy of the TestLimitOffset test) that can be dropped right in sqlserver_test.go:
I looked into common_sql_generator.go, LimitSQL, but since it only takes a fragment, not a template string or similar, there's no way to wrap the limit parameter. That might have to be an additional piece of configuration in the dialect, but I suspect you might have something similar used elsewhere that would be more appropriate/well-designed than my theoretical hack of a template string.
The text was updated successfully, but these errors were encountered:
Describe the bug
SQL Server requires
SELECT TOP (@p1) ...
when generating a parameterized statement (parentheses around the parameter, only for TOP). This library generatesSELECT TOP @p1 ...
which results in an error: mssql: Incorrect syntax near '@p1'To Reproduce
I wrote the following (a copy of the TestLimitOffset test) that can be dropped right in sqlserver_test.go:
Expected behavior
Running the tests produces the following output:
Dialect:
Additional context
This is a known SQL Server limitation that other people have also experienced in DB drivers, example: https://stackoverflow.com/questions/56132497/parametrizing-top-value-in-tsql-and-pyodbc
I looked into common_sql_generator.go, LimitSQL, but since it only takes a fragment, not a template string or similar, there's no way to wrap the limit parameter. That might have to be an additional piece of configuration in the dialect, but I suspect you might have something similar used elsewhere that would be more appropriate/well-designed than my theoretical hack of a template string.
The text was updated successfully, but these errors were encountered: