@@ -2972,13 +2972,13 @@ fn parse_create_single_mirror_no_options() {
2972
2972
assert_eq ! ( cdc. mirror_name, ObjectName ( vec![ Ident :: new( "test_mirror" ) ] ) ) ;
2973
2973
assert_eq ! ( cdc. source_peer, ObjectName ( vec![ Ident :: new( "p1" ) ] ) ) ;
2974
2974
assert_eq ! ( cdc. target_peer, ObjectName ( vec![ Ident :: new( "p2" ) ] ) ) ;
2975
- assert_eq ! ( cdc. table_mappings . len( ) , 1 ) ;
2975
+ assert_eq ! ( cdc. mappings . len( ) , 1 ) ;
2976
2976
assert_eq ! (
2977
- cdc. table_mappings [ 0 ] . source_table_identifier,
2977
+ cdc. mappings [ 0 ] . source_table_identifier,
2978
2978
ObjectName ( vec![ Ident :: new( "s1" ) , Ident :: new( "t1" ) ] )
2979
2979
) ;
2980
2980
assert_eq ! (
2981
- cdc. table_mappings [ 0 ] . target_table_identifier ,
2981
+ cdc. mappings [ 0 ] . target_identifier ,
2982
2982
ObjectName ( vec![ Ident :: new( "s2" ) , Ident :: new( "t2" ) ] )
2983
2983
) ;
2984
2984
assert_eq ! ( cdc. with_options. len( ) , 0 ) ;
@@ -3019,9 +3019,9 @@ fn parse_create_single_mirror() {
3019
3019
assert_eq ! ( cdc. mirror_name, ObjectName ( vec![ Ident :: new( "test_mirror" ) ] ) ) ;
3020
3020
assert_eq ! ( cdc. source_peer, ObjectName ( vec![ Ident :: new( "p1" ) ] ) ) ;
3021
3021
assert_eq ! ( cdc. target_peer, ObjectName ( vec![ Ident :: new( "p2" ) ] ) ) ;
3022
- assert_eq ! ( cdc. table_mappings . len( ) , 1 ) ;
3023
- assert_eq ! ( cdc. table_mappings [ 0 ] . source_table_identifier, ObjectName ( vec![ Ident :: new( "s1" ) , Ident :: new( "t1" ) ] ) ) ;
3024
- assert_eq ! ( cdc. table_mappings [ 0 ] . target_table_identifier , ObjectName ( vec![ Ident :: new( "s2" ) , Ident :: new( "t2" ) ] ) ) ;
3022
+ assert_eq ! ( cdc. mappings . len( ) , 1 ) ;
3023
+ assert_eq ! ( cdc. mappings [ 0 ] . source_table_identifier, ObjectName ( vec![ Ident :: new( "s1" ) , Ident :: new( "t1" ) ] ) ) ;
3024
+ assert_eq ! ( cdc. mappings [ 0 ] . target_identifier , ObjectName ( vec![ Ident :: new( "s2" ) , Ident :: new( "t2" ) ] ) ) ;
3025
3025
assert_eq ! ( cdc. with_options. len( ) , 1 ) ;
3026
3026
assert_eq ! ( cdc. with_options[ 0 ] . name, Ident :: new( "key1" ) ) ;
3027
3027
assert_eq ! ( cdc. with_options[ 0 ] . value, Value :: SingleQuotedString ( "value1" . into( ) ) ) ;
@@ -3038,16 +3038,39 @@ fn parse_create_multi_mirror() {
3038
3038
assert_eq ! ( cdc. mirror_name, ObjectName ( vec![ Ident :: new( "test_mirror" ) ] ) ) ;
3039
3039
assert_eq ! ( cdc. source_peer, ObjectName ( vec![ Ident :: new( "p1" ) ] ) ) ;
3040
3040
assert_eq ! ( cdc. target_peer, ObjectName ( vec![ Ident :: new( "p2" ) ] ) ) ;
3041
- assert_eq ! ( cdc. table_mappings . len( ) , 2 ) ;
3042
- assert_eq ! ( cdc. table_mappings [ 0 ] . source_table_identifier, ObjectName ( vec![ Ident :: new( "s1" ) , Ident :: new( "t1" ) ] ) ) ;
3043
- assert_eq ! ( cdc. table_mappings [ 0 ] . target_table_identifier , ObjectName ( vec![ Ident :: new( "s2" ) , Ident :: new( "t2" ) ] ) ) ;
3044
- assert_eq ! ( cdc. table_mappings [ 1 ] . source_table_identifier, ObjectName ( vec![ Ident :: new( "s1" ) , Ident :: new( "t3" ) ] ) ) ;
3045
- assert_eq ! ( cdc. table_mappings [ 1 ] . target_table_identifier , ObjectName ( vec![ Ident :: new( "s2" ) , Ident :: new( "t4" ) ] ) ) ;
3041
+ assert_eq ! ( cdc. mappings . len( ) , 2 ) ;
3042
+ assert_eq ! ( cdc. mappings [ 0 ] . source_table_identifier, ObjectName ( vec![ Ident :: new( "s1" ) , Ident :: new( "t1" ) ] ) ) ;
3043
+ assert_eq ! ( cdc. mappings [ 0 ] . target_identifier , ObjectName ( vec![ Ident :: new( "s2" ) , Ident :: new( "t2" ) ] ) ) ;
3044
+ assert_eq ! ( cdc. mappings [ 1 ] . source_table_identifier, ObjectName ( vec![ Ident :: new( "s1" ) , Ident :: new( "t3" ) ] ) ) ;
3045
+ assert_eq ! ( cdc. mappings [ 1 ] . target_identifier , ObjectName ( vec![ Ident :: new( "s2" ) , Ident :: new( "t4" ) ] ) ) ;
3046
3046
assert_eq ! ( cdc. with_options. len( ) , 2 ) ;
3047
3047
assert_eq ! ( cdc. with_options[ 0 ] . name, Ident :: new( "key1" ) ) ;
3048
3048
assert_eq ! ( cdc. with_options[ 0 ] . value, Value :: SingleQuotedString ( "value1" . into( ) ) ) ;
3049
3049
assert_eq ! ( cdc. with_options[ 1 ] . name, Ident :: new( "key2" ) ) ;
3050
3050
assert_eq ! ( cdc. with_options[ 1 ] . value, Value :: SingleQuotedString ( "value2" . into( ) ) ) ;
3051
+ assert_eq ! ( cdc. mapping_type, MappingType :: Table ) ;
3052
+ } ,
3053
+ _ => unreachable ! ( ) ,
3054
+ }
3055
+ }
3056
+
3057
+ #[ test]
3058
+ fn parse_create_mirror_with_schema ( ) {
3059
+ match pg ( ) . verified_stmt ( "CREATE MIRROR test_mirror FROM p1 TO p2 WITH SCHEMA MAPPING (s1:s2) WITH (key1 = 'value1', key2 = 'value2')" ) {
3060
+ Statement :: CreateMirror { if_not_exists, create_mirror : CDC ( cdc) } => {
3061
+ assert ! ( !if_not_exists) ;
3062
+ assert_eq ! ( cdc. mirror_name, ObjectName ( vec![ Ident :: new( "test_mirror" ) ] ) ) ;
3063
+ assert_eq ! ( cdc. source_peer, ObjectName ( vec![ Ident :: new( "p1" ) ] ) ) ;
3064
+ assert_eq ! ( cdc. target_peer, ObjectName ( vec![ Ident :: new( "p2" ) ] ) ) ;
3065
+ assert_eq ! ( cdc. mappings. len( ) , 1 ) ;
3066
+ assert_eq ! ( cdc. mappings[ 0 ] . source_table_identifier, ObjectName ( vec![ Ident :: new( "s1" ) ] ) ) ;
3067
+ assert_eq ! ( cdc. mappings[ 0 ] . target_identifier, ObjectName ( vec![ Ident :: new( "s2" ) ] ) ) ;
3068
+ assert_eq ! ( cdc. with_options. len( ) , 2 ) ;
3069
+ assert_eq ! ( cdc. with_options[ 0 ] . name, Ident :: new( "key1" ) ) ;
3070
+ assert_eq ! ( cdc. with_options[ 0 ] . value, Value :: SingleQuotedString ( "value1" . into( ) ) ) ;
3071
+ assert_eq ! ( cdc. with_options[ 1 ] . name, Ident :: new( "key2" ) ) ;
3072
+ assert_eq ! ( cdc. with_options[ 1 ] . value, Value :: SingleQuotedString ( "value2" . into( ) ) ) ;
3073
+ assert_eq ! ( cdc. mapping_type, MappingType :: Schema ) ;
3051
3074
} ,
3052
3075
_ => unreachable ! ( ) ,
3053
3076
}
0 commit comments