This commit is contained in:
2020-12-03 18:18:58 +00:00
parent 77d114743c
commit 5da01d776a

View File

@@ -21,7 +21,7 @@ namespace AyaNova.PickList
//Maximum number of results to return at any given time
//did a little research and may adjust this but it can be fairly girthy in this day and age
//and many people might not want or need to autocomplete type if we provide enough leeway.
//for example, if you're selecting a
const int MAXIMUM_RESULT_COUNT = 100;
//Build the query for a picklist request
@@ -52,6 +52,8 @@ namespace AyaNova.PickList
throw new System.ArgumentNullException($"DEV ERROR in PickListSqlBuilder.cs: picklist for {pickList.DefaultListObjectType.ToString()} has no rowId column specified in columnDefinitions list");
PlIdSelectFragment = rowIdColumn.SqlIdColumnName + " as plId";
if (preId != 0)
{
PredefinedOnlyWhereFragment = rowIdColumn.SqlIdColumnName + " = " + preId.ToString();
@@ -67,6 +69,7 @@ namespace AyaNova.PickList
AyaPickListFieldDefinition activeColumn = pickList.ColumnDefinitions.FirstOrDefault(z => z.IsActiveColumn == true);
if (activeColumn == null)
{
//no active column which is normal for some types of objects
//so make a fake one and return them all as active=true as all lists must return the same format
ActiveSelectFragment = "true as plActive";
@@ -83,7 +86,16 @@ namespace AyaNova.PickList
//if there is an override to see inactive too then we just don't set the filter on active
if (!IncludeInactive)
{
ActiveWhereFragment = activeColumn.SqlValueColumnName + " = true";
if (preId != 0)
{
//pre-selected need to always appear regardless of active status
ActiveWhereFragment = $"({rowIdColumn.SqlIdColumnName} = {preId}) or ({activeColumn.SqlValueColumnName} = true)";
}
else
{
ActiveWhereFragment = activeColumn.SqlValueColumnName + " = true";
}
}
}
@@ -169,10 +181,10 @@ namespace AyaNova.PickList
//Where fragment is different for non text fields: it needs to be cast to text to like query on it
//(cast (awidget.serial as text) like '%some%')
if (HasAutoCompleteQuery)
if (ServerGlobalBizSettings.SearchCaseSensitiveOnly)
sWhere = $"(cast ({valueColumnName} as text) like '%{autoCompleteQuery}%')";
if (ServerGlobalBizSettings.SearchCaseSensitiveOnly)
sWhere = $"(cast ({valueColumnName} as text) like '%{autoCompleteQuery}%')";
else
sWhere = $"(lower(cast ({valueColumnName} as text)) like lower('%{autoCompleteQuery}%'))";
sWhere = $"(lower(cast ({valueColumnName} as text)) like lower('%{autoCompleteQuery}%'))";
}