Skip to content

Commit 51865bf

Browse files
committed
Update to latest sqlparser version
1 parent 328c703 commit 51865bf

File tree

1 file changed

+14
-36
lines changed

1 file changed

+14
-36
lines changed

src/query_router.rs

+14-36
Original file line numberDiff line numberDiff line change
@@ -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(
550-
using_tbl_with_join,
528+
&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,7 @@ 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 == a.target.to_string().split(".").last().unwrap().to_lowercase()
826804
{
827805
return Err(Error::QueryRouterParserError(
828806
"Sharding key cannot be updated.".into(),

0 commit comments

Comments
 (0)