From d1e7de27b2e53bb001281118c7d64d2b60a30a52 Mon Sep 17 00:00:00 2001 From: John Cardinal Date: Wed, 18 Mar 2020 00:01:03 +0000 Subject: [PATCH] --- server/AyaNova/PickList/PickListSqlBuilder.cs | 30 ++++++++++++------- 1 file changed, 19 insertions(+), 11 deletions(-) diff --git a/server/AyaNova/PickList/PickListSqlBuilder.cs b/server/AyaNova/PickList/PickListSqlBuilder.cs index f947da32..7aa9fb1f 100644 --- a/server/AyaNova/PickList/PickListSqlBuilder.cs +++ b/server/AyaNova/PickList/PickListSqlBuilder.cs @@ -176,15 +176,20 @@ namespace AyaNova.PickList sb.Append(ActiveSelectFragment); sb.Append(", "); + //nope, this will return null if any of the values are null, very bad for this use, instead //select name || ' ' || serial || ' ' || array_to_string(tags,',') as display from awidget + //this, on the other hand will work even if all of them are null + //concat_ws(' ', awidget.name, awidget.serial, auser.name) + + sb.Append("concat_ws(' ', "); foreach (string s in lSelect) { sb.Append(s); - sb.Append(" || ' ' || ");//sb 11 characters + sb.Append(","); } - //clear trailing concat element - sb.Length -= 11;//length of last concat fragment above - sb.Append(" as plname"); + //clear trailing comma + sb.Length -= 1; + sb.Append(") as plname"); //FROM sb.Append(" "); @@ -223,13 +228,16 @@ namespace AyaNova.PickList sb.Append(")"); - }else{ - //we might have a trailing and to remove - //jesus this stuff sucks, there must be a better way, it seems so fragile - if(!IncludeInactive || HasTagSpecificQuery){ - //trailing " and " to remove - sb.Length-=5; - } + } + else + { + //we might have a trailing and to remove + //jesus this stuff sucks, there must be a better way, it seems so fragile + if (!IncludeInactive || HasTagSpecificQuery) + { + //trailing " and " to remove + sb.Length -= 5; + } } //ORDER BY