-
Notifications
You must be signed in to change notification settings - Fork 3.2k
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
FromSql(): Support passing a preamble SQL string #4976
Comments
Reading up on |
any update on this? |
If you're interested in contributing, start here in RelationalEntityQueryableExpressionVisitor. |
I've noticed a variation of this problem with simple queries (i.e. no CTE) where the query starts with a comment instead of the word In my example I'm reading the query as a string from an embedded resource then executing it with |
With the decision to stop doing client evaluation (#14935), does it make sense to stop doing any checks on the SQL altogether? If the user provides a non-composable SQL, they'd simply get a database error, which seems like the right thing... |
I'm hitting this as well. It would be nice to just stop validating SQL client-side and let the DB handle it, as @roji suggests... |
Clearing milestone so we can discuss in triage. |
@roji @khellang is the discussion to have in triage about the feature represented by this issue (enabling composability for SQL queries that require a preamble) or about not bothering trying to tell composable from non-composaable SQL. I see both as largely separate. Also I remember vaguely that @smitpatel was already tracking the latter somewhere else. |
@divega I think it's about the latter - removing any attempt to parse SQL and to identify composable vs. non-composable SQL. I took a quick look but couldn't find an issue tracking this - @smitpatel unless you have one I missed, I can open a new one. |
I am fine either way - tracking issue or not. |
OK, so I propose to close this issue and open another one tracking the removal of the composability check. Does that sound OK @divega @ajcvickers? |
@roji - negative. Even if the composability check is removed, AFAIK the functionality being talked about in this issue is still not possible. Without the check, we will just put it inside subquery when being composed over. And I am not sure |
Ah, I think I understand now (after reading this again) - sorry for the confusion. Returning to the backlog. Am not sure that an issue for removing the SQL composability checks is needed, but opened #15392 to track that. |
@roji - Thank you for contributing to my bucket of 3.0 issues. |
Always a pleasure Although this one seems simple enough that I could do it too.. |
At least we can close #15392 as fixed, presumably 😄 |
Maybe this documentation can help you in designing CTE API, it already works in production. Also there can be more than one CTE in query, and they need to be properly ordered by topological sort, so just adding additional FromSql implementation may introduce new bugs after query optimization. |
Currently whenever
FromSql()
detects a SQL string that does not start with the wordSELECT
, it treat it as a non-composable query and it evaluates the rest of the query on the client side.Some SQL constructs such as Common Table Expressions are fully composable but cannot be treated like normal SELECT statements in that they cannot be simply pushed down inside FROM clauses to become derived tables for a new SELECT.
It should be possible to support composability with CTEs if they could be specified separately from the SELECT, e.g. consider the following LINQ query (based on issue #4780):
For it, we would need to generate SQL similar to this:
The text was updated successfully, but these errors were encountered: