@@ -504,55 +504,33 @@ impl QueryRouter {
504504 let mut table_names = Vec :: new ( ) ;
505505
506506 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) => {
521508 // 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( ) ) ;
525512
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 ) ) ;
529516 }
530517 }
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 {
541520 exprs. push ( expr. clone ( ) ) ;
542521 }
543522
544523 // Multi tables delete are not supported in postgres.
545- assert ! ( tables. is_empty( ) ) ;
524+ assert ! ( d . tables. is_empty( ) ) ;
546525
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 {
549527 Self :: process_tables_with_join (
550528 using_tbl_with_join,
551529 & mut exprs,
552530 & mut table_names,
553531 ) ;
554532 }
555- Self :: process_selection ( selection, & mut exprs) ;
533+ Self :: process_selection ( & d . selection , & mut exprs) ;
556534 }
557535 Update {
558536 table,
@@ -822,7 +800,13 @@ impl QueryRouter {
822800
823801 for a in assignments {
824802 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 ( )
826810 {
827811 return Err ( Error :: QueryRouterParserError (
828812 "Sharding key cannot be updated." . into ( ) ,
0 commit comments