If I use the alias of Query.From(), I sometimes get the exception, e.g.
Database error 4104: The multi-part identifier "Org.UID_Org" could not be bound.
The simpliest example is this one-liner
session.Source().GetCollection(Query.From("Org", "o").Select("UID_Org"), EntityCollectionLoadType.Slim);
"Sometimes" here means it depends on the permission set. If I'm logged into OI with my dev-user, it works, if I use other users it won't work.
The full exception message is
Error during execution of statement: select o.UID_Org, xxxSelect.XGroupBitPattern as XSelectGroupBitPattern, xxxSelect.XGroupMask as XSelectGroupMask from Org o join
(
select sum(distinct(x.XGroupBitPattern)) as XGroupBitPattern, 0x80000000020000000000001000800000000020 as XGroupMask, XXPrimaryKey1
from(
select 28 as XGroupBitPattern, UID_Org as XXPrimaryKey1 from Org
union all
select 1 as XGroupBitPattern, UID_Org as XXPrimaryKey1 from Org where (UID_Org in (select c.UID_Org from dbo.QER_FTHelperHeadOrgChildren ('a69ccae8-38cc-4621-bfdb-6bed6a91858f') c) or UID_Org in (select c.UID_ParentOrg from dbo.QER_FTHelperHeadOrgParents ('a69ccae8-38cc-4621-bfdb-6bed6a91858f') c))
union all
select 2 as XGroupBitPattern, UID_Org as XXPrimaryKey1 from Org where (UID_Org in (select UID_Org from Person where UID_Person = 'a69ccae8-38cc-4621-bfdb-6bed6a91858f') Or UID_Org in (select UID_Org from PersonInOrg where UID_Person = 'a69ccae8-38cc-4621-bfdb-6bed6a91858f'))
) x
group by XXPrimaryKey1
) xxxSelect on xxxSelect.XXPrimaryKey1 = Org.UID_Org
Seems, like the alias is not used inside the inserted groupbitpattern-block - that should be o.UID_Org at the end.
So I think, Query.From(tableName, alias) is broken at the moment.
My questions are
- what is the underlying error here (what differences between my user and the other users leads to this error.. Sounds like DialogGroup.GroupBitPattern but I try to understand the problem thoroughly)
- are there more pitfalls (= "extensions" to the queries depending on the executing user)
- since this query (and also more complex ones) doesn't use the added columns at all, I wonder if there's some magic in behind (if a column is named XSelectGroupBitPattern, then something special is executed?). If so - which names are reserved for such behavior?