From 1d11af801925d7f6526b6d78577aa6968c055d3e Mon Sep 17 00:00:00 2001 From: Cannon Lock Date: Tue, 27 Feb 2024 14:17:47 -0600 Subject: [PATCH] Print Multiple Values rather then concating infinite strings --- api/query_parser.py | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/api/query_parser.py b/api/query_parser.py index 4b04ac5..df56986 100644 --- a/api/query_parser.py +++ b/api/query_parser.py @@ -13,7 +13,7 @@ from sqlalchemy.sql.expression import SQLColumnExpression -from sqlalchemy import and_, Column, not_, Table, func, distinct, cast, String +from sqlalchemy import and_, Column, not_, Table, func, distinct, cast, String, case VALID_OPERATORS = ["not", "eq", "lt", "le", "gt", "ge", "ne", "like", "in", "is"] @@ -112,9 +112,10 @@ def get_select_columns(self) -> list[Column]: columns.append(column) else: columns.append( - func.STRING_AGG(distinct(cast(column, String)), ",").label( - column.name - ) + case( + (func.count(distinct(cast(column, String))) > 5, "Multiple Values"), + else_=func.STRING_AGG(distinct(cast(column, String)), ",") + ).label(column.name) ) return columns