From 84dbf06991c0ee85fbcc988276774a6dff7265d5 Mon Sep 17 00:00:00 2001 From: John Cardinal Date: Fri, 13 Mar 2020 21:48:25 +0000 Subject: [PATCH] --- devdocs/todo.txt | 9 +++++++ server/AyaNova/PickList/PickListSqlBuilder.cs | 25 ++++++++++--------- 2 files changed, 22 insertions(+), 12 deletions(-) diff --git a/devdocs/todo.txt b/devdocs/todo.txt index 7a4a3675..ed892ea2 100644 --- a/devdocs/todo.txt +++ b/devdocs/todo.txt @@ -5,6 +5,15 @@ ## IMMEDIATE ITEMS +//PICKLISTS: + //TODO: build a sql List columnDefinitionsselect and order by and a where clause that searches appropriately in each field (tags) + //it should return results based on the query where there is a single name (display) column and an id column for rowid + //and the fields should be combined in a standard way separated by spaces "Widget widgetserial username" for compactness + //WORKING QUERY + //select awidget.id AS rowid,awidget.active,awidget.name,awidget.serial,auser.name from awidget left outer join auser on (awidget.userid=auser.id) + //where awidget.active = true and ((awidget.name like '%some%') or (cast (awidget.serial as text) like '%some%') or (auser.name like '%some%') ) order by awidget.name,awidget.serial,auser.name limit 100 + + TODO: BizRoles.cs seems to get hammered on every single request, is it efficient? - Why is it not cached in some way? diff --git a/server/AyaNova/PickList/PickListSqlBuilder.cs b/server/AyaNova/PickList/PickListSqlBuilder.cs index 4b55e115..05818e87 100644 --- a/server/AyaNova/PickList/PickListSqlBuilder.cs +++ b/server/AyaNova/PickList/PickListSqlBuilder.cs @@ -18,18 +18,9 @@ namespace AyaNova.PickList internal static string Build(IAyaPickList pickList, List templateColumnNames, string autoCompleteQuery, bool IncludeInactive) { - //TODO: if no autocompletequery returns the first XX results without querying in natural order by column names - //if autocomplete returns teh first XX results with query in natural order by column names - - //TODO: build a sql List columnDefinitionsselect and order by and a where clause that searches appropriately in each field (tags) - //it should return results based on the query where there is a single name (display) column and an id column for rowid - //and the fields should be combined in a standard way separated by spaces "Widget widgetserial username" for compactness - //WORKING QUERY - //select awidget.id AS rowid,awidget.active,awidget.name,awidget.serial,auser.name from awidget left outer join auser on (awidget.userid=auser.id) - //where awidget.active = true and ((awidget.name like '%some%') or (cast (awidget.serial as text) like '%some%') or (auser.name like '%some%') ) order by awidget.name,awidget.serial,auser.name limit 100 - - - //TODO: TAGS + + //TODO: custom template routes and tests + //TODO: TESTS FOR ALL FORMS OF QUERY (tags, non text fields etc) //TODO: Clean out unnneeded stuff in AyaPickListFieldDefinition (stuff from datalist copied over) //determine this in advance as it will be used in a loop later @@ -86,6 +77,16 @@ namespace AyaNova.PickList //Tag? if (o.ColumnDataType == UiFieldDataType.Tags) { + //awidget.tags @> array['blah','blah3'::varchar(255)] + //or in real life: ((awidget.name like '%o34%') or (awidget.tags @> array['zone-0'::varchar(255)]) ) + //but this means exact match only, not like comparison here + + //This also works: ((awidget.name like '%o34%') or ('blue' like any(awidget.tags)) ) + //but again, not a like query only exact match + + //THIS is the one: + //(array_to_string(awidget.tags,',') like '%zo%') + sWhere = $"(array_to_string({valueColumnName},',') like '%{autoCompleteQuery}%')"; } else if (o.ColumnDataType == UiFieldDataType.Text || o.ColumnDataType == UiFieldDataType.EmailAddress || o.ColumnDataType == UiFieldDataType.HTTP)