querybuilder
querybuilder copied to clipboard
Question mark in query breaks ToString
?
is a legal character in SQLServer, sadly.
Building following query would not work currently:
SELECT TOP(10) [A].[B] AS [TEST?] FROM [C]
But SQLServer is completely fine with this.
What breaks this is the fact that questionmarks are current used as placeholders for "bindings" such as TOP(?)
. And then later gets filled in here:
https://github.com/sqlkata/querybuilder/blob/ac897e0f430f13d494b79bbe00835282ef609bf9/QueryBuilder/SqlResult.cs#L53
But because the amount of question marks in the query is higher than the amount of bindings, an exception gets triggered here:
https://github.com/sqlkata/querybuilder/blob/ac897e0f430f13d494b79bbe00835282ef609bf9/QueryBuilder/SqlResult.cs#L57
Currently, I'm not aware of a character that wouldn't be a legal SQLServer character in this type of query to use as binding. Maybe something like SQLKATABINDING
has to be used instead, if you include that in your query you must just be trying to break it.
Honestly, it would be fine if this is kept this way and that's made clear but I doubt it's intended behavior.
Sorry that I have all these stupid edge-case issues, ha.