Skip to content

Commit

Permalink
rewrite limit
Browse files Browse the repository at this point in the history
  • Loading branch information
serprex committed Apr 30, 2024
1 parent cb69597 commit f9dff0b
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion nexus/peer-mysql/src/ast.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
use std::ops::ControlFlow;

use sqlparser::ast::{visit_relations_mut, Query};
use sqlparser::ast::{visit_relations_mut, Expr, Query};

pub fn rewrite_query(peername: &str, query: &mut Query) {
visit_relations_mut(query, |table| {
Expand All @@ -10,4 +10,9 @@ pub fn rewrite_query(peername: &str, query: &mut Query) {
}
ControlFlow::<()>::Continue(())
});

// postgres_fdw sends `limit 1` as `limit 1::bigint` which mysql chokes on
if let Some(Expr::Cast { expr, .. }) = &query.limit {
query.limit = Some((**expr).clone());
}
}

0 comments on commit f9dff0b

Please sign in to comment.