MCPcopy Create free account
hub / github.com/cowprotocol/services / insert_or_overwrite_interaction

Function insert_or_overwrite_interaction

crates/database/src/orders.rs:316–345  ·  view source on GitHub ↗
(
    ex: &mut PgConnection,
    interaction: &Interaction,
    order_uid: &OrderUid,
)

Source from the content-addressed store, hash-verified

314
315#[instrument(skip_all)]
316pub async fn insert_or_overwrite_interaction(
317 ex: &mut PgConnection,
318 interaction: &Interaction,
319 order_uid: &OrderUid,
320) -> Result<(), sqlx::Error> {
321 const QUERY: &str = r#"
322INSERT INTO interactions (
323 order_uid,
324 index,
325 target,
326 value,
327 data,
328 execution
329)
330VALUES ($1, $2, $3, $4, $5, $6)
331ON CONFLICT (order_uid, index, execution) DO UPDATE
332SET target = $3,
333value = $4, data = $5
334 "#;
335 sqlx::query(QUERY)
336 .bind(order_uid)
337 .bind(interaction.index)
338 .bind(interaction.target)
339 .bind(&interaction.value)
340 .bind(&interaction.data)
341 .bind(interaction.execution)
342 .execute(ex)
343 .await?;
344 Ok(())
345}
346
347/// One row in the `order_quotes` table.
348#[derive(Clone, Default, Debug, PartialEq, sqlx::FromRow)]

Calls 2

queryFunction · 0.85
executeMethod · 0.45

Tested by

no test coverage detected