Skip to content
This repository has been archived by the owner on Apr 26, 2024. It is now read-only.

Commit

Permalink
Allow passing where_clause through a simple_upsert into simple_upsert…
Browse files Browse the repository at this point in the history
…_txn
  • Loading branch information
realtyem committed Sep 12, 2023
1 parent 5d3e1eb commit 07234cb
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions synapse/storage/database.py
Original file line number Diff line number Diff line change
Expand Up @@ -1193,6 +1193,7 @@ async def simple_upsert(
keyvalues: Dict[str, Any],
values: Dict[str, Any],
insertion_values: Optional[Dict[str, Any]] = None,
where_clause: Optional[str] = None,
desc: str = "simple_upsert",
) -> bool:
"""Insert a row with values + insertion_values; on conflict, update with values.
Expand Down Expand Up @@ -1243,6 +1244,7 @@ async def simple_upsert(
keyvalues: The unique key columns and their new values
values: The nonunique columns and their new values
insertion_values: additional key/values to use only when inserting
where_clause: An index predicate to apply to the upsert.
desc: description of the transaction, for logging and metrics
Returns:
Returns True if a row was inserted or updated (i.e. if `values` is
Expand All @@ -1263,6 +1265,7 @@ async def simple_upsert(
keyvalues,
values,
insertion_values,
where_clause,
db_autocommit=autocommit,
)
except self.engine.module.IntegrityError as e:
Expand Down

0 comments on commit 07234cb

Please sign in to comment.