Page 1 of 1

Union/Concat bug in 5.70 release

Posted: Mon 24 May 2010 17:58
by Nahmis
First, thanks for the 5.70 updates, aside from what I'm about to post, this resolved every current issue we have (and that Enum announcement is very welcomed!)

Here's a simplified query demonstrating the issue:

Code: Select all

var docs = (from d in DB.Documents
            select new { d.Id, Role = d.DocumentName })
    .Concat(from d in DB.Documents
            select new { d.Id, Role = d.DocumentType });

var data = from d in DB.Documents
           join doc in docs on d.Id equals doc.Id
           select new {
               d.Id,
               ContactRole = doc.Role
           };
This generates the following SQL:

Code: Select all

SELECT t1.ID AS "Id", t2."DocumentType" AS "Role"      --should be t2."DocumentName" or t2."Role" 
FROM DOCUMENT t1
INNER JOIN (
    (
        SELECT t3.ID AS "Id", t3.DOCUMENT_NAME AS "DocumentName"
        FROM DOCUMENT t3
        )
    UNION ALL
    (
        SELECT t4.ID AS "Id", t4.DOCUMENT_TYPE AS "DocumentType"
        FROM DOCUMENT t4
        )
    ) t2 ON t1.ID = t2."Id"
The problem is it's trying to use the last concatenated query's columns for use in the overall query (we tested this with more queries, always the last one is used in this way), resulting in this error:

Code: Select all

Message ORA-00904: "T2"."DocumentType": invalid identifier
  
StackTrace    at xc.u.d()
   at Devart.Data.Oracle.bi.c()
   at Devart.Data.Oracle.q.a(Int32 A_0, a4 A_1)
   at Devart.Data.Oracle.OracleCommand.InternalExecute(CommandBehavior behavior, IDisposable disposable, Int32 startRecord, Int32 maxRecords, Boolean nonQuery)
   at Devart.Common.DbCommandBase.ExecuteDbDataReader(CommandBehavior behavior, Boolean nonQuery)
   at Devart.Common.DbCommandBase.ExecuteDbDataReader(CommandBehavior behavior)
   at System.Data.Common.DbCommand.System.Data.IDbCommand.ExecuteReader()
   at Devart.Data.Linq.Provider.DataProvider.ExecuteQuery(CompiledQuery compiledQuery, Object[] parentArgs, Object[] userArgs, Object lastResult)  
It needs to either use the first query's columns that oracle is expecting, or (even better in my opinion) use the name from the anonymous type I assigned, Role in this case. If you guys get a chance to fix this, I'd be happy to test, thanks!

Posted: Wed 26 May 2010 14:17
by AndreyR
Thank you for the report, we are investigating the situation.
I will let you know about the results of our investigaion.

Posted: Mon 05 Jul 2010 15:55
by AndreyR
This problem is already fixed in the current build.
Please let me know if anything goes wrong.