Skip to content

Commit

Permalink
Print Multiple Values rather then concating infinite strings
Browse files Browse the repository at this point in the history
  • Loading branch information
CannonLock committed Feb 27, 2024
1 parent 4524a5a commit 1d11af8
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions api/query_parser.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"]

Expand Down Expand Up @@ -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
Expand Down

0 comments on commit 1d11af8

Please sign in to comment.