@@ -9,10 +9,6 @@ mod tests {
99
1010 macro_rules! test_update_with_literal {
1111 ( $name: ident, $type: ident, $pg_type: ident) => {
12- test_update_with_literal!( $name, $type, $pg_type, false ) ;
13- } ;
14-
15- ( $name: ident, $type: ident, $pg_type: ident, $cast: expr) => {
1612 #[ tokio:: test]
1713 pub async fn $name( ) {
1814 trace( ) ;
@@ -27,35 +23,27 @@ mod tests {
2723
2824 let expected = vec![ encrypted_val. clone( ) ] ;
2925
30- let cast_to_type: & str = if $cast {
31- & format!( "::{}" , stringify!( $pg_type) )
32- } else {
33- ""
34- } ;
35-
3626 // First insert a record
37- let insert_sql = format!( "INSERT INTO encrypted (id, {encrypted_col}) VALUES ($1, $2)" ) ;
27+ let insert_sql =
28+ format!( "INSERT INTO encrypted (id, {encrypted_col}) VALUES ($1, $2)" ) ;
3829 execute_query( & insert_sql, & [ & id, & initial_val] ) . await ;
3930
4031 // Then update it with literal value
41- let update_sql = format!( "UPDATE encrypted SET {encrypted_col} = '{encrypted_val}'{cast_to_type} WHERE id = $1" ) ;
42- let select_sql = format!( "SELECT {encrypted_col}{cast_to_type} FROM encrypted WHERE id = $1" ) ;
32+ let update_sql = format!(
33+ "UPDATE encrypted SET {encrypted_col} = '{encrypted_val}' WHERE id = $1"
34+ ) ;
35+ let select_sql = format!( "SELECT {encrypted_col} FROM encrypted WHERE id = $1" ) ;
4336
4437 execute_query( & update_sql, & [ & id] ) . await ;
4538 let actual = query_by:: <$type>( & select_sql, & id) . await ;
4639
4740 assert_eq!( expected, actual) ;
48-
4941 }
5042 } ;
5143 }
5244
5345 macro_rules! test_update_simple_query_with_literal {
5446 ( $name: ident, $type: ident, $pg_type: ident) => {
55- test_update_simple_query_with_literal!( $name, $type, $pg_type, false ) ;
56- } ;
57-
58- ( $name: ident, $type: ident, $pg_type: ident, $cast: expr) => {
5947 #[ tokio:: test]
6048 pub async fn $name( ) {
6149 trace( ) ;
@@ -69,20 +57,13 @@ mod tests {
6957 let initial_val = crate :: value_for_type!( $type, 1 ) ;
7058 let encrypted_val = crate :: value_for_type!( $type, random_limited( ) ) ;
7159
72- let cast_to_type: & str = if $cast {
73- & format!( "::{}" , stringify!( $pg_type) )
74- } else {
75- ""
76- } ;
77-
7860 // First insert a record
79- let insert_sql = format!( "INSERT INTO encrypted (id, {encrypted_col}) VALUES ({id}, '{initial_val}'{cast_to_type} )" ) ;
61+ let insert_sql = format!( "INSERT INTO encrypted (id, {encrypted_col}) VALUES ({id}, '{initial_val}')" ) ;
8062 execute_simple_query( & insert_sql) . await ;
8163
8264 // Then update it with literal value
83- let update_sql = format!( "UPDATE encrypted SET {encrypted_col} = '{encrypted_val}'{cast_to_type} WHERE id = {id}" ) ;
84- let select_sql = format!( "SELECT {encrypted_col}{cast_to_type} FROM encrypted WHERE id = {id}" ) ;
85-
65+ let update_sql = format!( "UPDATE encrypted SET {encrypted_col} = '{encrypted_val}' WHERE id = {id}" ) ;
66+ let select_sql = format!( "SELECT {encrypted_col} FROM encrypted WHERE id = {id}" ) ;
8667
8768 let expected = vec![ encrypted_val] ;
8869
@@ -101,7 +82,7 @@ mod tests {
10182 test_update_with_literal ! ( update_with_literal_bool, bool , bool ) ;
10283 test_update_with_literal ! ( update_with_literal_text, String , text) ;
10384 test_update_with_literal ! ( update_with_literal_date, NaiveDate , date) ;
104- test_update_with_literal ! ( update_with_literal_jsonb, Value , jsonb, true ) ;
85+ test_update_with_literal ! ( update_with_literal_jsonb, Value , jsonb) ;
10586
10687 test_update_simple_query_with_literal ! ( update_simple_query_with_literal_int2, i16 , int2) ;
10788 test_update_simple_query_with_literal ! ( update_simple_query_with_literal_int4, i32 , int4) ;
@@ -110,12 +91,7 @@ mod tests {
11091 test_update_simple_query_with_literal ! ( update_simple_query_with_literal_bool, bool , bool ) ;
11192 test_update_simple_query_with_literal ! ( update_simple_query_with_literal_text, String , text) ;
11293 test_update_simple_query_with_literal ! ( update_simple_query_with_literal_date, NaiveDate , date) ;
113- test_update_simple_query_with_literal ! (
114- update_simple_query_with_literal_jsonb,
115- Value ,
116- jsonb,
117- true
118- ) ;
94+ test_update_simple_query_with_literal ! ( update_simple_query_with_literal_jsonb, Value , jsonb) ;
11995
12096 // -----------------------------------------------------------------
12197
0 commit comments