Skip to content

Commit 868ffb8

Browse files
M03EDImMohammad20000
authored andcommitted
fix(node): postgresql query
1 parent e7b7157 commit 868ffb8

File tree

1 file changed

+10
-1
lines changed

1 file changed

+10
-1
lines changed

app/node/user.py

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,12 +26,21 @@ def serialize_user_for_node(id: int, username: str, user_settings: dict, inbound
2626

2727

2828
async def core_users(db: AsyncSession):
29+
dialect = db.bind.dialect.name
30+
31+
# Use dialect-specific aggregation function
32+
if dialect == "postgresql":
33+
inbound_agg = func.string_agg(ProxyInbound.tag.distinct(), ",").label("inbound_tags")
34+
else:
35+
# MySQL and SQLite use group_concat
36+
inbound_agg = func.group_concat(ProxyInbound.tag.distinct()).label("inbound_tags")
37+
2938
stmt = (
3039
select(
3140
User.id,
3241
User.username,
3342
User.proxy_settings,
34-
func.group_concat(ProxyInbound.tag.distinct()).label("inbound_tags"),
43+
inbound_agg,
3544
)
3645
.outerjoin(users_groups_association, User.id == users_groups_association.c.user_id)
3746
.outerjoin(

0 commit comments

Comments
 (0)