@@ -26,13 +26,14 @@ use crate::prometheus::{
2626use crate :: Encrypted ;
2727use bytes:: BytesMut ;
2828use cipherstash_client:: encryption:: Plaintext ;
29- use eql_mapper:: { self , EqlMapperError , EqlValue , NodeKey , TableColumn , TypedStatement } ;
29+ use eql_mapper:: { self , EqlMapperError , EqlValue , TableColumn , TypedStatement } ;
3030use metrics:: { counter, histogram} ;
3131use pg_escape:: quote_literal;
3232use serde:: Serialize ;
33- use sqlparser:: ast:: { self , Expr , Value } ;
34- use sqlparser:: dialect:: PostgreSqlDialect ;
35- use sqlparser:: parser:: Parser ;
33+ use sqltk_parser:: ast:: { self , Value } ;
34+ use sqltk_parser:: dialect:: PostgreSqlDialect ;
35+ use sqltk_parser:: parser:: Parser ;
36+ use sqltk:: AsNodeKey ;
3637use std:: collections:: HashMap ;
3738use std:: time:: Instant ;
3839use tokio:: io:: { AsyncRead , AsyncWrite , AsyncWriteExt } ;
@@ -285,7 +286,7 @@ where
285286
286287 match self . to_encryptable_statement ( & typed_statement, vec ! [ ] ) ? {
287288 Some ( statement) => {
288- if statement. has_literals ( ) || typed_statement . has_nodes_to_wrap ( ) {
289+ if statement. has_literals ( ) {
289290 let encrypted_literals = self
290291 . encrypt_literals ( & typed_statement, & statement. literal_columns )
291292 . await ?;
@@ -421,16 +422,15 @@ where
421422 . literals
422423 . iter ( )
423424 . zip ( encrypted_expressions. into_iter ( ) )
424- . filter_map ( |( ( _, original_node) , en) | en. map ( |en| ( NodeKey :: new ( * original_node) , en) ) )
425+ . filter_map ( |( ( _, original_node) , en) | en. map ( |en| ( original_node. as_node_key ( ) , en) ) )
425426 . collect :: < HashMap < _ , _ > > ( ) ;
426427
427428 debug ! ( target: MAPPER ,
428429 client_id = self . context. client_id,
429- nodes_to_wrap = typed_statement. nodes_to_wrap. len( ) ,
430430 literals = encrypted_nodes. len( ) ,
431431 ) ;
432432
433- if !typed_statement . has_nodes_to_wrap ( ) && encrypted_nodes. is_empty ( ) {
433+ if encrypted_nodes. is_empty ( ) {
434434 return Ok ( None ) ;
435435 }
436436
@@ -500,7 +500,7 @@ where
500500
501501 match self . to_encryptable_statement ( & typed_statement, param_types) ? {
502502 Some ( statement) => {
503- if statement. has_literals ( ) || typed_statement . has_nodes_to_wrap ( ) {
503+ if statement. has_literals ( ) {
504504 let encrypted_literals = self
505505 . encrypt_literals ( & typed_statement, & statement. literal_columns )
506506 . await ?;
@@ -620,7 +620,6 @@ where
620620 if ( param_columns. is_empty ( ) || no_encrypted_param_columns)
621621 && ( projection_columns. is_empty ( ) || no_encrypted_projection_columns)
622622 && literal_columns. is_empty ( )
623- && !typed_statement. has_nodes_to_wrap ( )
624623 {
625624 return Ok ( None ) ;
626625 }
@@ -781,7 +780,7 @@ where
781780 typed_statement : & eql_mapper:: TypedStatement < ' _ > ,
782781 ) -> Result < Vec < Option < Column > > , Error > {
783782 let mut projection_columns = vec ! [ ] ;
784- if let Some ( eql_mapper:: Projection :: WithColumns ( columns) ) = & typed_statement. projection {
783+ if let eql_mapper:: Projection :: WithColumns ( columns) = & typed_statement. projection {
785784 for col in columns {
786785 let eql_mapper:: ProjectionColumn { ty, .. } = col;
787786 let configured_column = match ty {
@@ -819,7 +818,7 @@ where
819818
820819 for param in typed_statement. params . iter ( ) {
821820 let configured_column = match param {
822- eql_mapper:: Value :: Eql ( EqlValue ( TableColumn { table, column } ) ) => {
821+ ( _ , eql_mapper:: Value :: Eql ( EqlValue ( TableColumn { table, column } ) ) ) => {
823822 let identifier = Identifier :: from ( ( table, column) ) ;
824823
825824 debug ! (
@@ -967,9 +966,9 @@ fn literals_to_plaintext(
967966 Ok ( plaintexts)
968967}
969968
970- fn to_json_literal_expr < T > ( literal : & T ) -> Result < Expr , Error >
969+ fn to_json_literal_expr < T > ( literal : & T ) -> Result < Value , Error >
971970where
972971 T : ?Sized + Serialize ,
973972{
974- Ok ( serde_json:: to_string ( literal) . map ( |json| Expr :: Value ( Value :: SingleQuotedString ( json ) ) ) ?)
973+ Ok ( serde_json:: to_string ( literal) . map ( Value :: SingleQuotedString ) ?)
975974}
0 commit comments