Skip to content

Commit

Permalink
Include props in element query
Browse files Browse the repository at this point in the history
  • Loading branch information
ckrapu-nv committed Mar 3, 2025
1 parent 8eedc01 commit de33538
Showing 1 changed file with 9 additions and 3 deletions.
12 changes: 9 additions & 3 deletions backend/chainlit/data/sql_alchemy.py
Original file line number Diff line number Diff line change
Expand Up @@ -519,7 +519,12 @@ async def create_element(self, element: "Element"):

columns = ", ".join(f'"{column}"' for column in element_dict_cleaned.keys())
placeholders = ", ".join(f":{column}" for column in element_dict_cleaned.keys())
query = f"INSERT INTO elements ({columns}) VALUES ({placeholders})"
updates = ", ".join(
f'"{column}" = :{column}'
for column in element_dict_cleaned.keys()
if column != "id"
)
query = f"INSERT INTO elements ({columns}) VALUES ({placeholders}) ON CONFLICT (id) DO UPDATE SET {updates};"
await self.execute_sql(query=query, parameters=element_dict_cleaned)

@queue_until_user_message()
Expand Down Expand Up @@ -627,7 +632,8 @@ async def get_all_user_threads(
e."language" AS element_language,
e."page" AS element_page,
e."forId" AS element_forid,
e."mime" AS element_mime
e."mime" AS element_mime,
e."props" AS props
FROM elements e
WHERE e."threadId" IN {thread_ids}
"""
Expand Down Expand Up @@ -712,7 +718,7 @@ async def get_all_user_threads(
autoPlay=element.get("element_autoPlay"),
playerConfig=element.get("element_playerconfig"),
page=element.get("element_page"),
props=json.loads(element.get("props", "{}")),
props=element.get("props", "{}"),
forId=element.get("element_forid"),
mime=element.get("element_mime"),
)
Expand Down

0 comments on commit de33538

Please sign in to comment.