1d5cb6a53674b76c2f8d4f8413a69b10124d9cbc
galt
  Wed Oct 5 16:02:16 2022 -0700
Fixing a few more minor bugs for sqlSafef V2 in CIRM cdwWebBrowse.

diff --git src/hg/lib/tablesTables.c src/hg/lib/tablesTables.c
index 5cb4f42..ce546f2 100644
--- src/hg/lib/tablesTables.c
+++ src/hg/lib/tablesTables.c
@@ -882,30 +882,31 @@
 		    sqlDyStringPrintf(where, "%s", remaining);
 		    }
 		else
 		    {
 		    warn("Filter for %s doesn't parse:  %s", field->name, val);
 		    sqlDyStringPrintf(where, "%s is not null", field->name); // Let query continue
 		    }
 		}
 	    else
 		{
 		sqlDyStringPrintf(where, "%s = '%s'", field->name, val);
 		}
 	    }
 	}
     }
+if (!isEmpty(where->string))
     sqlDyStringPrintf(query, "%-s", where->string);  // trust
 
 /* We do order here so as to keep order when working with tables bigger than a page. */
 char orderVar[256];
 safef(orderVar, sizeof(orderVar), "%s_order", varPrefix);
 char *orderFields = cartUsualString(cart, orderVar, "");
 if (!isEmpty(orderFields))
     {
     if (orderFields[0] == '-')
 	sqlDyStringPrintf(query, " order by %s desc", orderFields+1);
     else
 	sqlDyStringPrintf(query, " order by %s", orderFields);
     }
 
 // return query and where expression