Skip to content

Rename a couple of variables #839

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Oct 23, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions src/query_router.rs
Original file line number Diff line number Diff line change
Expand Up @@ -386,14 +386,14 @@ impl QueryRouter {
}
}

/// Determines if a query is mutable or not.
fn query_is_mutable_statement(q: &sqlparser::ast::Query) -> bool {
/// Determines if a query is a mutation or not.
fn is_mutation_query(q: &sqlparser::ast::Query) -> bool {
use sqlparser::ast::*;

match q.body.as_ref() {
SetExpr::Insert(_) => true,
SetExpr::Update(_) => true,
SetExpr::Query(q) => Self::query_is_mutable_statement(q),
SetExpr::Query(q) => Self::is_mutation_query(q),
_ => false,
}
}
Expand Down Expand Up @@ -440,9 +440,9 @@ impl QueryRouter {
};

let has_locks = !query.locks.is_empty();
let is_mutable_statement = Self::query_is_mutable_statement(query);
let has_mutation = Self::is_mutation_query(query);

if has_locks || is_mutable_statement {
if has_locks || has_mutation {
self.active_role = Some(Role::Primary);
} else if !visited_write_statement {
// If we already visited a write statement, we should be going to the primary.
Expand Down