@@ -504,55 +504,33 @@ impl QueryRouter {
504
504
let mut table_names = Vec :: new ( ) ;
505
505
506
506
match q {
507
- Insert {
508
- or,
509
- into : _,
510
- table_name,
511
- columns,
512
- overwrite : _,
513
- source,
514
- partitioned,
515
- after_columns,
516
- table : _,
517
- on : _,
518
- returning : _,
519
- ignore : _,
520
- } => {
507
+ Insert ( i) => {
521
508
// Not supported in postgres.
522
- assert ! ( or. is_none( ) ) ;
523
- assert ! ( partitioned. is_none( ) ) ;
524
- assert ! ( after_columns. is_empty( ) ) ;
509
+ assert ! ( i . or. is_none( ) ) ;
510
+ assert ! ( i . partitioned. is_none( ) ) ;
511
+ assert ! ( i . after_columns. is_empty( ) ) ;
525
512
526
- Self :: process_table ( table_name, & mut table_names) ;
527
- if let Some ( source) = source {
528
- Self :: process_query ( source, & mut exprs, & mut table_names, & Some ( columns) ) ;
513
+ Self :: process_table ( & i . table_name , & mut table_names) ;
514
+ if let Some ( source) = & i . source {
515
+ Self :: process_query ( source, & mut exprs, & mut table_names, & Some ( & i . columns ) ) ;
529
516
}
530
517
}
531
- Delete {
532
- tables,
533
- from,
534
- using,
535
- selection,
536
- returning : _,
537
- order_by : _,
538
- limit : _,
539
- } => {
540
- if let Some ( expr) = selection {
518
+ Delete ( d) => {
519
+ if let Some ( expr) = & d. selection {
541
520
exprs. push ( expr. clone ( ) ) ;
542
521
}
543
522
544
523
// Multi tables delete are not supported in postgres.
545
- assert ! ( tables. is_empty( ) ) ;
524
+ assert ! ( d . tables. is_empty( ) ) ;
546
525
547
- Self :: process_tables_with_join ( from, & mut exprs, & mut table_names) ;
548
- if let Some ( using_tbl_with_join) = using {
526
+ if let Some ( using_tbl_with_join) = & d. using {
549
527
Self :: process_tables_with_join (
550
528
using_tbl_with_join,
551
529
& mut exprs,
552
530
& mut table_names,
553
531
) ;
554
532
}
555
- Self :: process_selection ( selection, & mut exprs) ;
533
+ Self :: process_selection ( & d . selection , & mut exprs) ;
556
534
}
557
535
Update {
558
536
table,
@@ -822,7 +800,13 @@ impl QueryRouter {
822
800
823
801
for a in assignments {
824
802
if sharding_key[ 0 ] . value == "*"
825
- && sharding_key[ 1 ] . value == a. id . last ( ) . unwrap ( ) . value . to_lowercase ( )
803
+ && sharding_key[ 1 ] . value
804
+ == a. target
805
+ . to_string ( )
806
+ . split ( '.' )
807
+ . last ( )
808
+ . unwrap ( )
809
+ . to_lowercase ( )
826
810
{
827
811
return Err ( Error :: QueryRouterParserError (
828
812
"Sharding key cannot be updated." . into ( ) ,
0 commit comments