From 97e402c76c97296ea126122a5d032e35226a5009 Mon Sep 17 00:00:00 2001 From: John Cardinal Date: Fri, 8 Oct 2021 19:54:07 +0000 Subject: [PATCH] --- devdocs/solutions.txt | 4 +- .../DataListSqlFilterCriteriaBuilder.cs | 45 +++++++++++++++++++ 2 files changed, 48 insertions(+), 1 deletion(-) diff --git a/devdocs/solutions.txt b/devdocs/solutions.txt index 0d570850..231b5334 100644 --- a/devdocs/solutions.txt +++ b/devdocs/solutions.txt @@ -256,4 +256,6 @@ America/Los_Angeles Create a new db, run this once: c:\data\code\postgres_14\bin\initdb -D ^"C^:^\data^\code^\postgres^_14^\ayanova^" -U postgres -A trust that's it, run it with: - C:\data\code\postgres_14\bin\pg_ctl -D ^"C^:^\data^\code^\postgres^_14^\ayanova^" -l logfile start \ No newline at end of file + C:\data\code\postgres_14\bin\pg_ctl -D ^"C^:^\data^\code^\postgres^_14^\ayanova^" -l logfile start + + Note: for test win64 build just copy the empty db files generated above (before any access is done) into the C:\data\code\raven\dist\win-x64\data\database folder \ No newline at end of file diff --git a/server/AyaNova/DataList/DataListSqlFilterCriteriaBuilder.cs b/server/AyaNova/DataList/DataListSqlFilterCriteriaBuilder.cs index c1f7ce2f..df4a5e87 100644 --- a/server/AyaNova/DataList/DataListSqlFilterCriteriaBuilder.cs +++ b/server/AyaNova/DataList/DataListSqlFilterCriteriaBuilder.cs @@ -313,6 +313,51 @@ namespace AyaNova.DataList } #endregion build text ops criteria break; + + + case UiFieldDataType.Roles: + { + /* + So Roles can be queried as contains or NOT contains with a bitwise & + also a Equals or NOt equals with a direct equality comparison + + CONTAINS: + User selects roles, query checks if a user has all the roles the user selected with this query: + single OpsAdminRestricted (8192): + select name, roles from auser where (roles & 8192 = 8192) order by name + + User has OpsAdminRestricted (8192) and SubContractorRestricted (512) which client will return as 8704: + select name, roles from auser where (roles & 8704 = 8704) order by name + brings up users with both opsadminrestricted and subconctractorrestricted and possibly others doesn't matter + + + EQUALITY: + just a simple = or <> i.e. where roles=4096 or roles!=4096 + + + */ + switch (sOperator) + { + case DataListFilterComparisonOperator.Equality: + sb.Append($"= ${sValue} "); + break; + + case DataListFilterComparisonOperator.NotEqual: + sb.Append($"<> ${sValue}"); + break; + case DataListFilterComparisonOperator.Contains: + sb.Append($"& ${sValue}=${sValue} "); + break; + case DataListFilterComparisonOperator.NotContains: + sb.Append($"& ${sValue}!=${sValue} "); + break; + default: + throw new System.ArgumentOutOfRangeException("OPERATOR_TYPE", sOperator, "DataListSqlFilterCriteriaBuilder unhandled operator type [" + sOperator + "] in ROLES"); + + } + } + break; + case UiFieldDataType.Bool: { switch (sOperator)