Fix rowid to_sql_string printing

This commit is contained in:
pedrocarlo 2025-06-09 12:10:34 -03:00
parent cb4efdbc19
commit 36f60e4dd1
2 changed files with 9 additions and 6 deletions

View file

@ -6,7 +6,10 @@ use constraints::{
use cost::Cost;
use join::{compute_best_join_order, BestJoinOrderResult};
use lift_common_subexpressions::lift_common_subexpressions_from_binary_or_terms;
use limbo_sqlite3_parser::ast::{self, Expr, SortOrder};
use limbo_sqlite3_parser::{
ast::{self, Expr, SortOrder},
to_sql_string::ToSqlString as _,
};
use order::{compute_order_target, plan_satisfies_order_target, EliminatesSort};
use crate::{
@ -45,6 +48,8 @@ pub fn optimize_plan(plan: &mut Plan, schema: &Schema) -> Result<()> {
}
}
}
// When debug tracing is enabled, print the optimized plan as a SQL string for debugging
tracing::debug!(plan_sql = plan.to_sql_string(&crate::translate::display::PlanContext(&[])));
Ok(())
}

View file

@ -146,11 +146,9 @@ impl ToSqlString for Expr {
ret.push('.');
ret.push_str(context.get_column_name(*table, *column));
}
// TODO: not sure how to rewrite this
Expr::RowId {
database: _,
table: _,
} => todo!(),
Expr::RowId { database: _, table } => {
ret.push_str(&format!("{}.rowid", context.get_table_name(*table)))
}
Expr::InList { lhs, not, rhs } => {
ret.push_str(&format!(
"{} {}IN ({})",