Join GitHub today
GitHub is home to over 28 million developers working together to host and review code, manage projects, and build software together.Sign up
Incorrect DDEX SQL validation #2136
I have an issue where for certain sql, when I run it through the querybuilder, it first parsers the query and returns an error/warning.
For example, when I run this simple query:
I get the following error message:
Then when I hit the OK button the query is run successfully.
Would you be able to tell me the origin of this error, is it from Npgsql or from Visual Studio itself.
Is there any way for me to override this warning or modify the parser?
Npgsql version: 3.2.6
Right... But PostgreSQL doesn't define
It would be helpful if you could give us some more information on what exactly you're trying to do, how you're trying to do it, etc.
Yes, you're right, in postgreSQL the N prefix will declare the string as a VARCHAR rather then text.
Please don't get caught up in the actual N prefix, I was just using this statement as a simple example to generate the error in the visual studio querybuilder. I'm trying to figure out how the querybuilder parses the sql statement in order to generate the error/warning. I have a scenario where I need to modify the validation that is occurring on the sql statement and can't figure out where this is happening. Is it the DDEX layer or the Npgsql driver parsing the query in order to generate the warning or is it Visual Studio itself doing the validity check?
@warcha Ah, thank you for clarifying. I was indeed preoccupied with your example, apologies.
I would be surprised if Npgsql was performing any sort of query validation on the client. Our standard approach is to defer to PostgreSQL when feasible. But, the DDEX plumbing is a bit beyond my depth, so I may be mistaken.
@roji Could you weigh in?
changed the title from
Querybuilder sql parsing issue
Incorrect DDEX SQL validation
Aug 30, 2018
Npgsql definitely does not look at or validate any SQL, ever (except for some light parsing to split on semicolons and replace parameter placeholders).
In addition, PostgreSQL does indeed support SELECT without FROM:
This is very likely coming from Visual Studio itself or DDEX - someone is performing client-side validation. However, ADO.NET providers such as Npgsql do expose some metadata properties which tell DDEX whether some SQL feature is supported or not: take a look at the
As a way forward, I'd examine the schema collections returned by MSSQL, there may be an undocumented property returned there that controls this, in which case we can change Npgsql to return it too.
Hope all that is clear...