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.
Nice catch, the problem here is that even in Raw Statements the user is allowed to enter the ? as a parameter placeholder,
db.Query("Users").WhereRaw("Id = ?", new [] { 1 });
using longer placeholder would make this more tedious, so mentioning this in the docs would be helpful.
I have to allow using ? in SELECT, Any possible work around? Please help here.