From 27e20e15f7ca0d45200c8e70070be47e658fee70 Mon Sep 17 00:00:00 2001 From: Daniel Schick Date: Wed, 11 Dec 2024 09:39:26 +0100 Subject: [PATCH] fixed bug in participant API GET with user_id parameter --- src/server/BreCal/impl/participant.py | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/src/server/BreCal/impl/participant.py b/src/server/BreCal/impl/participant.py index 0365d8a..421523c 100644 --- a/src/server/BreCal/impl/participant.py +++ b/src/server/BreCal/impl/participant.py @@ -19,8 +19,13 @@ def GetParticipant(options): # query = SQLQuery.get_participant_by_user_id() query = ("SELECT p.id as id, p.name as name, p.street as street, p.postal_code as postal_code, p.city as city, p.type as type, p.flags as flags, " + "p.created as created, p.modified as modified, p.deleted as deleted FROM participant p " + - "INNER JOIN user u WHERE u.participant_id = p.id and u.id = %d") % options["user_id"] + "INNER JOIN user u WHERE u.participant_id = p.id and u.id = %s") % options["user_id"] data = commands.query(query, model=model.Participant) + for participant in data: + port_query = "SELECT port_id FROM participant_port_map WHERE participant_id=?id?" + for record in commands.query(port_query, model=model.Port_Assignment, param={"id" : participant.id}, buffered=False): + pa = model.Port_Assignment(record.port_id) + participant.ports.append(pa.port_id) else: # query = SQLQuery.get_participants() if "participant_id" in options: @@ -29,7 +34,7 @@ def GetParticipant(options): "FROM participant p " + "JOIN participant_port_map ON p.id = participant_port_map.participant_id " + "WHERE participant_port_map.port_id IN " + - "(SELECT port_id FROM participant_port_map where participant_id = %d) " + + "(SELECT port_id FROM participant_port_map where participant_id = %s) " + "GROUP BY id " + "ORDER BY p.name") % options["participant_id"] else: @@ -41,7 +46,7 @@ def GetParticipant(options): data = commands.query(query, model=model.Participant) for participant in data: - port_query = "SELECT port_id FROM participant_port_map WHERE participant_id=?id?"; + port_query = "SELECT port_id FROM participant_port_map WHERE participant_id=?id?" for record in commands.query(port_query, model=model.Port_Assignment, param={"id" : participant.id}, buffered=False): pa = model.Port_Assignment(record.port_id) participant.ports.append(pa.port_id)