querybuilder
querybuilder copied to clipboard
Sqlite Compiler wraps columns into string literals, preventing the 'No Such Column' exception from occurring (returning the string literal instead of throwing)
Take the following database table: Table: Students ID (int) - FirstName (string) - LastName (string)
Use the following query:
var qry = new SqlKata.Query("Students").Select("UnknownCol")
You will receive the string literal 'UnknownCol' back as a result.
The resulting query is as follows:
SELECT \"UnknownCol\" FROM \"Students\"
Modifying the above to use brackets instead results in the No Such Column
exception being thrown properly.
SELECT [UnknownCol] FROM [Students]
For reference, I am using DBCommand.ExecuteScalar() to retrieve the value from the database
Reference to my downvoted StackOverflow thread. Because apparently I'm the first one ever to have an issue with string literals. https://stackoverflow.com/questions/75040657/sqlite-database-returns-nonexistant-column-name-instead-of-exception-due-to-bad