OData / odataorg.github.io

Staging site and collaboration repository for http://www.odata.org
MIT License
63 stars 101 forks source link

Sql generated using oData #198

Closed zburek13 closed 4 years ago

zburek13 commented 4 years ago

When using oData's "countdistinct" in my request http://page/route?$apply=aggregate(prop with countdistinct as result)

following sql is generated:

SELECT 
1 AS "C1", 
'result' AS "C2", 
"Project3"."C1" AS "C3"
FROM ( SELECT 
    (SELECT 
        COUNT(1) AS "A1"
        FROM ( SELECT DISTINCT 
            "Extent2"."PROP" AS "PROP"
            FROM "SCHEMA"."TABLE" "Extent2"
            WHERE ("Distinct1"."C1" = 1)
        )  "Distinct2") AS "C1"
    FROM ( SELECT DISTINCT 
        1 AS "C1"
        FROM "SCHEMA"."TABLE" "Extent1"
    )  "Distinct1"
)  "Project3"

That throws an error ORA-00904: "Distinct1"."C1": invalid identifier If WHERE clause is removed from everything works fine and results are valid.

Environment: Oracle Database 11g Release 11.2.0.1.0 - 64bit Production

EntityFramework 6.2.0 Oracle.ManagedDataAccess 12.2.1100 Oracle.ManagedDataAccess.EntityFramework 12.2.110

Microsoft.Data.Odata 5.8.3 Microsoft.OData.Core 7.4.4 Microsoft.OData.Edm 7.4.4 Microsoft.AspNet.OData 6.1.0

Tried: Updating packages- -> did not work Connecting to database other then Oracle and use "countdistinct" -> it works fine.