@@ -688,7 +688,8 @@ mod tests {
688688
689689 use super :: * ;
690690 use crate :: store:: postgres:: query:: {
691- Alias , PostgresQueryPath as _, SelectCompiler , test_helper:: max_version_expression,
691+ Alias , Identifier , PostgresQueryPath as _, SelectCompiler ,
692+ test_helper:: max_version_expression,
692693 } ;
693694
694695 #[ test]
@@ -800,6 +801,99 @@ mod tests {
800801 assert_eq ! ( empty_array. transpile_to_string( ) , "ARRAY[]::text[]" ) ;
801802 }
802803
804+ #[ test]
805+ fn transpile_null_constant ( ) {
806+ assert_eq ! (
807+ Expression :: Constant ( Constant :: Null ) . transpile_to_string( ) ,
808+ "NULL"
809+ ) ;
810+ }
811+
812+ #[ test]
813+ fn transpile_u128_constant ( ) {
814+ assert_eq ! (
815+ Expression :: Constant ( Constant :: U128 (
816+ 340_282_366_920_938_463_463_374_607_431_768_211_455
817+ ) )
818+ . transpile_to_string( ) ,
819+ "340282366920938463463374607431768211455"
820+ ) ;
821+ }
822+
823+ #[ test]
824+ fn transpile_json_agg ( ) {
825+ assert_eq ! (
826+ Expression :: Function ( Function :: JsonAgg ( Box :: new( Expression :: Parameter ( 1 ) ) ) )
827+ . transpile_to_string( ) ,
828+ "jsonb_agg($1)"
829+ ) ;
830+ }
831+
832+ #[ test]
833+ fn transpile_unnest_multiple ( ) {
834+ assert_eq ! (
835+ Expression :: Function ( Function :: Unnest ( vec![
836+ Expression :: Parameter ( 1 ) ,
837+ Expression :: Parameter ( 2 ) ,
838+ Expression :: Parameter ( 3 ) ,
839+ ] ) )
840+ . transpile_to_string( ) ,
841+ "UNNEST($1, $2, $3)"
842+ ) ;
843+ }
844+
845+ #[ test]
846+ fn transpile_field_access ( ) {
847+ assert_eq ! (
848+ Expression :: FieldAccess {
849+ expr: Box :: new( Expression :: Parameter ( 1 ) ) ,
850+ field: ColumnName :: from( Identifier :: from( "filter" ) ) ,
851+ }
852+ . transpile_to_string( ) ,
853+ r#"($1)."filter""#
854+ ) ;
855+ }
856+
857+ #[ test]
858+ fn transpile_is_not_false ( ) {
859+ assert_eq ! (
860+ Expression :: Unary ( UnaryExpression {
861+ op: UnaryOperator :: IsNotFalse ,
862+ expr: Box :: new( Expression :: Parameter ( 1 ) ) ,
863+ } )
864+ . transpile_to_string( ) ,
865+ "$1 IS NOT FALSE"
866+ ) ;
867+ }
868+
869+ #[ test]
870+ fn transpile_cast_types ( ) {
871+ assert_eq ! (
872+ Expression :: Parameter ( 1 )
873+ . cast( PostgresType :: JsonB )
874+ . transpile_to_string( ) ,
875+ "($1::jsonb)"
876+ ) ;
877+ assert_eq ! (
878+ Expression :: Parameter ( 1 )
879+ . cast( PostgresType :: Numeric )
880+ . transpile_to_string( ) ,
881+ "($1::numeric)"
882+ ) ;
883+ assert_eq ! (
884+ Expression :: Parameter ( 1 )
885+ . cast( PostgresType :: Int )
886+ . transpile_to_string( ) ,
887+ "($1::int)"
888+ ) ;
889+ assert_eq ! (
890+ Expression :: Parameter ( 1 )
891+ . cast( PostgresType :: BigInt )
892+ . transpile_to_string( ) ,
893+ "($1::bigint)"
894+ ) ;
895+ }
896+
803897 fn test_condition < ' p , ' f : ' p > (
804898 filter : & ' f Filter < ' p , DataTypeWithMetadata > ,
805899 rendered : & ' static str ,
0 commit comments