Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Sqlite Compiler wraps columns into string literals, preventing the 'No Such Column' exception from occurring (returning the string literal instead of throwing) #655

Open
RFBomb opened this issue Jan 7, 2023 · 0 comments

Comments

@RFBomb
Copy link
Contributor

RFBomb commented Jan 7, 2023

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

@RFBomb RFBomb changed the title Sqlite Compiler wraps columns into string literals, preventing the 'No Such Column' exception from occurring Sqlite Compiler wraps columns into string literals, preventing the 'No Such Column' exception from occurring (returning the string literal instead of throwing) Jan 7, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant