I struggled with this fragment, giving me this message;
def sqlLimit(limit: Int): Fragment = fr"TOP $limit "
Exception in thread "main" com.microsoft.sqlserver.jdbc.SQLServerException: Incorrect syntax near '@P0'.
Which I think I managed to track back to this stackoverflow;
https://stackoverflow.com/questions/7038818/ms-sql-exception-incorrect-syntax-near-p0
So, in SQL server apparently, this fragment should be
def sqlLimit(limit: Int): Fragment = fr"TOP ( $limit )"
Because "limit" is a variable, it must have brackets (apparently) - and then query worked. I then come to trying to unit test it...
Adding the brackets into the "TOP" fragment, appears to generate this error in Test.
? SQL Compiles and TypeChecks
The number of rows provided for a TOP or FETCH clauses row count
parameter must be an integer.
It's obviously a niche use case!
Based on a discord exchange;
this is probably a bug in the mssql jdbc driver
doobie can't do anything about it
Filed here for posterity - if I can figure out a way to show it's the msql driver, then I'll file it upstream, but not quite sure how to write that our properly right now.
I struggled with this fragment, giving me this message;
def sqlLimit(limit: Int): Fragment = fr"TOP $limit "
Which I think I managed to track back to this stackoverflow;
https://stackoverflow.com/questions/7038818/ms-sql-exception-incorrect-syntax-near-p0
So, in SQL server apparently, this fragment should be
Because "limit" is a variable, it must have brackets (apparently) - and then query worked. I then come to trying to unit test it...
Adding the brackets into the "TOP" fragment, appears to generate this error in Test.
It's obviously a niche use case!
Based on a discord exchange;
Filed here for posterity - if I can figure out a way to show it's the msql driver, then I'll file it upstream, but not quite sure how to write that our properly right now.