@@ -460,6 +460,7 @@ impl UserQuery {
460460 if let Some ( lit) = expr_to_bytes ( right) {
461461 if let Some ( param) = self . get_param ( left) {
462462 * right = match param {
463+ abi:: Parameter :: Tuple { .. } => right. clone ( ) ,
463464 abi:: Parameter :: Address { .. } | abi:: Parameter :: Uint { .. } => {
464465 ast:: Expr :: Value ( ast:: Value :: SingleQuotedString ( format ! (
465466 r#"\x{}"# ,
@@ -596,24 +597,15 @@ impl UserQuery {
596597 ast:: Expr :: IsNotFalse ( _) => Ok ( ( ) ) ,
597598 ast:: Expr :: IsTrue ( _) => Ok ( ( ) ) ,
598599 ast:: Expr :: IsNotTrue ( _) => Ok ( ( ) ) ,
599- ast:: Expr :: IsNull ( _ ) => Ok ( ( ) ) ,
600- ast:: Expr :: IsNotNull ( _ ) => Ok ( ( ) ) ,
600+ ast:: Expr :: IsNull ( expr ) => self . validate_expression ( expr ) ,
601+ ast:: Expr :: IsNotNull ( expr ) => self . validate_expression ( expr ) ,
601602 ast:: Expr :: Ceil { expr, field : _ } => self . validate_expression ( expr) ,
602603 ast:: Expr :: Floor { expr, field : _ } => self . validate_expression ( expr) ,
603604 ast:: Expr :: Value ( _) => Ok ( ( ) ) ,
604605 ast:: Expr :: Exists { subquery, .. } => self . validate_query ( subquery) ,
605606 ast:: Expr :: Subquery ( subquery) => self . validate_query ( subquery) ,
606607 ast:: Expr :: Tuple ( exprs) => self . validate_expressions ( exprs) ,
607608 ast:: Expr :: UnaryOp { expr, .. } => self . validate_expression ( expr) ,
608- ast:: Expr :: BinaryOp {
609- left,
610- right,
611- op : ast:: BinaryOperator :: LongArrow | ast:: BinaryOperator :: Arrow ,
612- ..
613- } => {
614- self . validate_expression ( left) ?;
615- self . validate_expression ( right)
616- }
617609 ast:: Expr :: BinaryOp { left, right, .. } => {
618610 self . set_chain ( left, right) ;
619611 self . rewrite_binary_expr ( left, right) ?;
@@ -658,7 +650,7 @@ impl UserQuery {
658650
659651 fn validate_function ( & mut self , function : & mut ast:: Function ) -> Result < ( ) , api:: Error > {
660652 let name = function. name . to_string ( ) . to_lowercase ( ) ;
661- const VALID_FUNCS : [ & str ; 14 ] = [
653+ const VALID_FUNCS : [ & str ; 15 ] = [
662654 "coalesce" ,
663655 "min" ,
664656 "max" ,
@@ -673,6 +665,7 @@ impl UserQuery {
673665 "abi_uint" ,
674666 "abi_int" ,
675667 "abi_string" ,
668+ "jsonb_path_query_array" ,
676669 ] ;
677670 if !VALID_FUNCS . contains ( & name. as_str ( ) ) {
678671 return no ! ( format!( r#"'{}' function"# , name) ) ;
@@ -810,6 +803,9 @@ fn bytes_to_expr(bytes: Vec<u8>, to: ast::DataType) -> Result<ast::Expr, api::Er
810803 value : s,
811804 } )
812805 }
806+ ast:: DataType :: JSONB => Ok ( ast:: Expr :: Value ( ast:: Value :: SingleQuotedString (
807+ String :: from_utf8 ( bytes) . map_err ( |_| api:: Error :: User ( "invalid JSONB" . to_string ( ) ) ) ?,
808+ ) ) ) ,
813809 _ => Err ( api:: Error :: User ( format ! (
814810 "unable to convert {bytes:?} to {to:?}" ,
815811 ) ) ) ,
@@ -831,9 +827,10 @@ fn base_column_type(id: &Ident) -> Option<ast::DataType> {
831827
832828 // Txs
833829 "idx" | "type" => Some ( ast:: DataType :: Int64 ) ,
834- "from" | "to" | "input" => Some ( ast:: DataType :: Bytea ) ,
830+ "from" | "to" | "input" | "fee_token" => Some ( ast:: DataType :: Bytea ) ,
835831 "value" => Some ( ast:: DataType :: Numeric ( ast:: ExactNumberInfo :: None ) ) ,
836832 "gas" | "gas_price" => Some ( ast:: DataType :: Numeric ( ast:: ExactNumberInfo :: None ) ) ,
833+ "calls" => Some ( ast:: DataType :: JSONB ) ,
837834
838835 // Logs
839836 "tx_hash" | "address" | "topics" | "data" => Some ( ast:: DataType :: Bytea ) ,
0 commit comments