From 602673f7d097d1104113f8a2e43a9f5a333e4427 Mon Sep 17 00:00:00 2001 From: Michael Cuffaro Date: Tue, 23 Jan 2024 13:17:47 -0500 Subject: [PATCH] add optional row number parameter to validate_row() --- src/api_test.rs | 12 ++++++------ src/lib.rs | 3 ++- 2 files changed, 8 insertions(+), 7 deletions(-) diff --git a/src/api_test.rs b/src/api_test.rs index 65d8039f..eba2acd5 100644 --- a/src/api_test.rs +++ b/src/api_test.rs @@ -58,13 +58,13 @@ async fn test_idempotent_validate_and_update(valve: &Valve) -> Result<(), ValveE }); let result_row_1 = valve - .validate_row("table2", row.as_object().unwrap()) + .validate_row("table2", row.as_object().unwrap(), None) .await?; - let result_row_2 = valve.validate_row("table2", &result_row_1).await?; + let result_row_2 = valve.validate_row("table2", &result_row_1, None).await?; assert_eq!(result_row_1, result_row_2); - let result_row = valve.validate_row("table2", &result_row_2).await?; + let result_row = valve.validate_row("table2", &result_row_2, None).await?; assert_eq!(result_row, result_row_2); // Update the row we constructed and validated above in the database: @@ -95,7 +95,7 @@ async fn test_validate_and_insert_1(valve: &Valve) -> Result<(), ValveError> { }); let result_row = valve - .validate_row("table3", row.as_object().unwrap()) + .validate_row("table3", row.as_object().unwrap(), None) .await?; let (_new_row_num, _new_row) = valve.insert_row("table3", &result_row).await?; @@ -123,7 +123,7 @@ async fn test_validate_and_update(valve: &Valve) -> Result<(), ValveError> { }); let result_row = valve - .validate_row("table6", row.as_object().unwrap()) + .validate_row("table6", row.as_object().unwrap(), None) .await?; valve.update_row("table6", &1, &result_row).await?; @@ -151,7 +151,7 @@ async fn test_validate_and_insert_2(valve: &Valve) -> Result<(), ValveError> { }); let result_row = valve - .validate_row("table6", row.as_object().unwrap()) + .validate_row("table6", row.as_object().unwrap(), None) .await?; let (_new_row_num, _new_row) = valve.insert_row("table6", &result_row).await?; diff --git a/src/lib.rs b/src/lib.rs index 543066e5..56c7f8af 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -1411,6 +1411,7 @@ impl Valve { &self, table_name: &str, row: &ValveRow, + row_number: Option, ) -> Result { validate_row_tx( &self.config, @@ -1420,7 +1421,7 @@ impl Valve { None, table_name, row, - None, + row_number, None, ) .await