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
Invalid sub-query SQL generated #4160
Comments
Another question. Your old versions used to generate sub-queries and your new versions generate OUTER APPLY clauses. I liked sub-queries better. Is there a way to choose old behavior? |
Try to add |
Hey guys, any update on this? |
Will try to check it in next couple of weeks. Don't have much time currently |
Try the following query as workaround: var data = (
from pe in db.PERSON
from cc in db.CITY
.Where(cc => cc.CITYCODE == pe.CITYCODE)
.Take(1)
.DefaultIfEmpty()
select new
{
CURRENCYCALCULATEDSYMBOL = cc.CITYNAME,
}).Distinct().ToList(); |
Thanks for that. |
Change happended in 3.0.0-preview.2 Old sql SELECT DISTINCT
(
SELECT
cc_1.CITYNAME
FROM
CITY cc_1
WHERE
ROWNUM <= 1 AND (cc_1.CITYCODE IS NULL AND pe.CITYCODE IS NULL OR cc_1.CITYCODE = pe.CITYCODE)
),
(
SELECT
cc_2.CITYNAME
FROM
CITY cc_2
WHERE
ROWNUM <= 1 AND (cc_2.CITYCODE IS NULL AND pe.CITYCODE IS NULL OR cc_2.CITYCODE = pe.CITYCODE)
)
FROM
PERSON pe |
Probably by this PR #2087 |
Actually both queries (old version and new) look strange. Providers without APPLY support generate more sane SQL: SELECT DISTINCT
(
SELECT
cc.CITYNAME
FROM
CITY cc
WHERE
(cc.CITYCODE = pe.CITYCODE OR cc.CITYCODE IS NULL AND pe.CITYCODE IS NULL) AND
ROWNUM <= :take
)
FROM
PERSON pe |
Honestly, I'm not sure why you added support for APPLY. Wondering what was your motivation? |
While APPLY is not being necessary in this specific case, we still need it for more complex queries. |
Hey guys! |
Hi guys! |
Please see demo project attached.
We are facing an issue where when we're trying to use sub-query, Linq2Db is creating an invalid SQL query.
Below is the query that gets executed when we run the scenario.
As you can see, the inner select statement returns 2 values in this scenario which results in a "ORA-00913: too many values" error.
------Linq------
------Linq------
------Generated SQL------
------Generated SQL------
LinqToDbIssueDemo.zip
The text was updated successfully, but these errors were encountered: