@@ -9408,3 +9408,59 @@ fn insert_into_with_parentheses() {
94089408 } ;
94099409 dialects. verified_stmt ( "INSERT INTO t1 (id, name) (SELECT t2.id, t2.name FROM t2)" ) ;
94109410}
9411+
9412+ #[ test]
9413+ fn test_dictionary_syntax ( ) {
9414+ fn check ( sql : & str , expect : Expr ) {
9415+ assert_eq ! (
9416+ all_dialects_where( |d| d. supports_dictionary_syntax( ) ) . verified_expr( sql) ,
9417+ expect
9418+ ) ;
9419+ }
9420+
9421+ check (
9422+ "{'Alberta': 'Edmonton', 'Manitoba': 'Winnipeg'}" ,
9423+ Expr :: Dictionary ( vec ! [
9424+ DictionaryField {
9425+ key: Ident :: with_quote( '\'' , "Alberta" ) ,
9426+ value: Box :: new( Expr :: Value ( Value :: SingleQuotedString (
9427+ "Edmonton" . to_owned( ) ,
9428+ ) ) ) ,
9429+ } ,
9430+ DictionaryField {
9431+ key: Ident :: with_quote( '\'' , "Manitoba" ) ,
9432+ value: Box :: new( Expr :: Value ( Value :: SingleQuotedString (
9433+ "Winnipeg" . to_owned( ) ,
9434+ ) ) ) ,
9435+ } ,
9436+ ] ) ,
9437+ ) ;
9438+
9439+ check (
9440+ "{'start': CAST('2023-04-01' AS TIMESTAMP), 'end': CAST('2023-04-05' AS TIMESTAMP)}" ,
9441+ Expr :: Dictionary ( vec ! [
9442+ DictionaryField {
9443+ key: Ident :: with_quote( '\'' , "start" ) ,
9444+ value: Box :: new( Expr :: Cast {
9445+ kind: CastKind :: Cast ,
9446+ expr: Box :: new( Expr :: Value ( Value :: SingleQuotedString (
9447+ "2023-04-01" . to_owned( ) ,
9448+ ) ) ) ,
9449+ data_type: DataType :: Timestamp ( None , TimezoneInfo :: None ) ,
9450+ format: None ,
9451+ } ) ,
9452+ } ,
9453+ DictionaryField {
9454+ key: Ident :: with_quote( '\'' , "end" ) ,
9455+ value: Box :: new( Expr :: Cast {
9456+ kind: CastKind :: Cast ,
9457+ expr: Box :: new( Expr :: Value ( Value :: SingleQuotedString (
9458+ "2023-04-05" . to_owned( ) ,
9459+ ) ) ) ,
9460+ data_type: DataType :: Timestamp ( None , TimezoneInfo :: None ) ,
9461+ format: None ,
9462+ } ) ,
9463+ } ,
9464+ ] ) ,
9465+ )
9466+ }
0 commit comments