From c10512b26a9a385b0042d71f72206803cbf8f47d Mon Sep 17 00:00:00 2001 From: Andrii Demus Date: Wed, 8 Jan 2025 13:40:41 +0100 Subject: [PATCH] Preserve original formatting --- ...ece20ea61b689ec9e98a3a955e52f2a7b782.json} | 4 +-- ...dda132b5d484ee0e88da24759583ead5ccb6.json} | 4 +-- .../postgres/src/postgres_flow_event_store.rs | 14 +++------- .../sqlite/src/sqlite_flow_event_store.rs | 28 ++++++++----------- 4 files changed, 19 insertions(+), 31 deletions(-) rename src/infra/flow-system/postgres/.sqlx/{query-109bbf2c14a2da5aa46bca81a79a25bf58f4ca6003dbc1bfc832ecd444ba2c16.json => query-82f1523001347f5984f9c9a44f1aece20ea61b689ec9e98a3a955e52f2a7b782.json} (59%) rename src/infra/flow-system/postgres/.sqlx/{query-f017c67fa362c0a1557effc9f5df30251d7716ceee9004b2405f6dd37faf15d9.json => query-c6c83bf1eda6fcc75731d78f7926dda132b5d484ee0e88da24759583ead5ccb6.json} (59%) diff --git a/src/infra/flow-system/postgres/.sqlx/query-109bbf2c14a2da5aa46bca81a79a25bf58f4ca6003dbc1bfc832ecd444ba2c16.json b/src/infra/flow-system/postgres/.sqlx/query-82f1523001347f5984f9c9a44f1aece20ea61b689ec9e98a3a955e52f2a7b782.json similarity index 59% rename from src/infra/flow-system/postgres/.sqlx/query-109bbf2c14a2da5aa46bca81a79a25bf58f4ca6003dbc1bfc832ecd444ba2c16.json rename to src/infra/flow-system/postgres/.sqlx/query-82f1523001347f5984f9c9a44f1aece20ea61b689ec9e98a3a955e52f2a7b782.json index dcf95fc57..4b816f609 100644 --- a/src/infra/flow-system/postgres/.sqlx/query-109bbf2c14a2da5aa46bca81a79a25bf58f4ca6003dbc1bfc832ecd444ba2c16.json +++ b/src/infra/flow-system/postgres/.sqlx/query-82f1523001347f5984f9c9a44f1aece20ea61b689ec9e98a3a955e52f2a7b782.json @@ -1,6 +1,6 @@ { "db_name": "PostgreSQL", - "query": "\n SELECT\n flow_id\n FROM flows\n WHERE\n dataset_id = ANY($1)\n AND (cast($2 as dataset_flow_type) IS NULL OR dataset_flow_type = $2)\n AND (cast($3 as flow_status_type) IS NULL OR flow_status = $3)\n AND (cast($4 as TEXT[]) IS NULL OR initiator = ANY($4))\n ORDER BY flow_status, last_event_id DESC\n LIMIT $5 OFFSET $6\n ", + "query": "\n SELECT flow_id FROM flows\n WHERE dataset_id = ANY($1)\n AND (cast($2 as dataset_flow_type) IS NULL OR dataset_flow_type = $2)\n AND (cast($3 as flow_status_type) IS NULL OR flow_status = $3)\n AND (cast($4 as TEXT[]) IS NULL OR initiator = ANY($4))\n ORDER BY flow_status, last_event_id DESC\n LIMIT $5 OFFSET $6\n ", "describe": { "columns": [ { @@ -46,5 +46,5 @@ false ] }, - "hash": "109bbf2c14a2da5aa46bca81a79a25bf58f4ca6003dbc1bfc832ecd444ba2c16" + "hash": "82f1523001347f5984f9c9a44f1aece20ea61b689ec9e98a3a955e52f2a7b782" } diff --git a/src/infra/flow-system/postgres/.sqlx/query-f017c67fa362c0a1557effc9f5df30251d7716ceee9004b2405f6dd37faf15d9.json b/src/infra/flow-system/postgres/.sqlx/query-c6c83bf1eda6fcc75731d78f7926dda132b5d484ee0e88da24759583ead5ccb6.json similarity index 59% rename from src/infra/flow-system/postgres/.sqlx/query-f017c67fa362c0a1557effc9f5df30251d7716ceee9004b2405f6dd37faf15d9.json rename to src/infra/flow-system/postgres/.sqlx/query-c6c83bf1eda6fcc75731d78f7926dda132b5d484ee0e88da24759583ead5ccb6.json index e37c5f4dc..efce10ea9 100644 --- a/src/infra/flow-system/postgres/.sqlx/query-f017c67fa362c0a1557effc9f5df30251d7716ceee9004b2405f6dd37faf15d9.json +++ b/src/infra/flow-system/postgres/.sqlx/query-c6c83bf1eda6fcc75731d78f7926dda132b5d484ee0e88da24759583ead5ccb6.json @@ -1,6 +1,6 @@ { "db_name": "PostgreSQL", - "query": "\n SELECT\n flow_id\n FROM flows\n WHERE\n dataset_id = $1\n AND (cast($2 as dataset_flow_type) IS NULL OR dataset_flow_type = $2)\n AND (cast($3 as flow_status_type) IS NULL OR flow_status = $3)\n AND (cast($4 as TEXT[]) IS NULL OR initiator = ANY($4))\n ORDER BY flow_status, last_event_id DESC\n LIMIT $5 OFFSET $6\n ", + "query": "\n SELECT flow_id FROM flows\n WHERE dataset_id = $1\n AND (cast($2 as dataset_flow_type) IS NULL OR dataset_flow_type = $2)\n AND (cast($3 as flow_status_type) IS NULL OR flow_status = $3)\n AND (cast($4 as TEXT[]) IS NULL OR initiator = ANY($4))\n ORDER BY flow_status, last_event_id DESC\n LIMIT $5 OFFSET $6\n ", "describe": { "columns": [ { @@ -46,5 +46,5 @@ false ] }, - "hash": "f017c67fa362c0a1557effc9f5df30251d7716ceee9004b2405f6dd37faf15d9" + "hash": "c6c83bf1eda6fcc75731d78f7926dda132b5d484ee0e88da24759583ead5ccb6" } diff --git a/src/infra/flow-system/postgres/src/postgres_flow_event_store.rs b/src/infra/flow-system/postgres/src/postgres_flow_event_store.rs index d7b98e611..170594f01 100644 --- a/src/infra/flow-system/postgres/src/postgres_flow_event_store.rs +++ b/src/infra/flow-system/postgres/src/postgres_flow_event_store.rs @@ -592,11 +592,8 @@ impl FlowEventStore for PostgresFlowEventStore { let mut query_stream = sqlx::query!( r#" - SELECT - flow_id - FROM flows - WHERE - dataset_id = $1 + SELECT flow_id FROM flows + WHERE dataset_id = $1 AND (cast($2 as dataset_flow_type) IS NULL OR dataset_flow_type = $2) AND (cast($3 as flow_status_type) IS NULL OR flow_status = $3) AND (cast($4 as TEXT[]) IS NULL OR initiator = ANY($4)) @@ -681,11 +678,8 @@ impl FlowEventStore for PostgresFlowEventStore { let mut query_stream = sqlx::query!( r#" - SELECT - flow_id - FROM flows - WHERE - dataset_id = ANY($1) + SELECT flow_id FROM flows + WHERE dataset_id = ANY($1) AND (cast($2 as dataset_flow_type) IS NULL OR dataset_flow_type = $2) AND (cast($3 as flow_status_type) IS NULL OR flow_status = $3) AND (cast($4 as TEXT[]) IS NULL OR initiator = ANY($4)) diff --git a/src/infra/flow-system/sqlite/src/sqlite_flow_event_store.rs b/src/infra/flow-system/sqlite/src/sqlite_flow_event_store.rs index f8ff257b2..dc6281ded 100644 --- a/src/infra/flow-system/sqlite/src/sqlite_flow_event_store.rs +++ b/src/infra/flow-system/sqlite/src/sqlite_flow_event_store.rs @@ -78,9 +78,9 @@ impl SqliteFlowEventStore { dataset_flow_type, initiator, ) - .execute(connection_mut) - .await - .map_err(ErrorIntoInternal::int_err)?; + .execute(connection_mut) + .await + .map_err(ErrorIntoInternal::int_err)?; } FlowKey::System(fk_system) => { let system_flow_type = fk_system.flow_type; @@ -165,9 +165,9 @@ impl SqliteFlowEventStore { maybe_scheduled_for_activation_at, maybe_prev_stored_event_id, ) - .fetch_all(connection_mut) - .await - .map_err(|e| SaveEventsError::Internal(e.int_err()))?; + .fetch_all(connection_mut) + .await + .map_err(|e| SaveEventsError::Internal(e.int_err()))?; // If a previously stored event id does not match the expected, // this means we've just detected a concurrent modification (version conflict) @@ -646,14 +646,11 @@ impl FlowEventStore for SqliteFlowEventStore { let query_str = format!( r#" - SELECT - flow_id - FROM flows - WHERE - dataset_id = $1 + SELECT flow_id FROM flows + WHERE dataset_id = $1 AND (cast($2 as dataset_flow_type) IS NULL OR dataset_flow_type = $2) AND (cast($3 as flow_status_type) IS NULL OR flow_status = $3) - AND ($4 = 0 OR initiator in ({})) + AND ($4 = 0 OR initiator IN ({})) ORDER BY flow_status DESC, last_event_id DESC LIMIT $5 OFFSET $6 "#, @@ -760,11 +757,8 @@ impl FlowEventStore for SqliteFlowEventStore { let query_str = format!( r#" - SELECT - flow_id - FROM flows - WHERE - dataset_id in ({}) + SELECT flow_id FROM flows + WHERE dataset_id in ({}) AND (cast($1 as dataset_flow_type) IS NULL OR dataset_flow_type = $1) AND (cast($2 as flow_status_type) IS NULL OR flow_status = $2) AND ($3 = 0 OR initiator in ({}))