mirror of
https://github.com/t8y2/dbx.git
synced 2026-10-23 02:40:11 +00:00
fix: format bool as 0/1 for all BIT columns, not just MySQL
This commit is contained in:
@@ -765,10 +765,17 @@ pub fn format_grid_sql_literal(
|
||||
if value.is_null() {
|
||||
return "NULL".to_string();
|
||||
}
|
||||
if is_mysql_bit_literal_column(database_type, column_info) {
|
||||
if let Some(value) = value.as_bool() {
|
||||
// Boolean values on BIT columns always use numeric 0/1.
|
||||
// This covers MySQL, SQL Server, and any other database where BIT
|
||||
// is a numeric/boolean type rather than a bit-string type like
|
||||
// PostgreSQL's bit(n).
|
||||
if let Some(value) = value.as_bool() {
|
||||
if is_bit_literal_column(column_info) {
|
||||
return if value { "1" } else { "0" }.to_string();
|
||||
}
|
||||
return if value { "TRUE" } else { "FALSE" }.to_string();
|
||||
}
|
||||
if is_mysql_bit_literal_column(database_type, column_info) {
|
||||
if let Some(number) = value.as_number() {
|
||||
return number.to_string();
|
||||
}
|
||||
@@ -776,9 +783,6 @@ pub fn format_grid_sql_literal(
|
||||
return text;
|
||||
}
|
||||
}
|
||||
if let Some(value) = value.as_bool() {
|
||||
return if value { "TRUE" } else { "FALSE" }.to_string();
|
||||
}
|
||||
if let Some(number) = value.as_number() {
|
||||
return number.to_string();
|
||||
}
|
||||
@@ -819,6 +823,10 @@ fn is_mysql_bit_literal_column(database_type: Option<DatabaseType>, column_info:
|
||||
&& column_info.map(|column| is_bit_column_type(&column.data_type)).unwrap_or(false)
|
||||
}
|
||||
|
||||
fn is_bit_literal_column(column_info: Option<&DataGridColumnInfo>) -> bool {
|
||||
column_info.map(|column| is_bit_column_type(&column.data_type)).unwrap_or(false)
|
||||
}
|
||||
|
||||
fn is_bit_column_type(data_type: &str) -> bool {
|
||||
let lower = data_type.to_ascii_lowercase();
|
||||
lower.split(|ch: char| !ch.is_ascii_alphanumeric()).any(|token| token == "bit")
|
||||
|
||||
Reference in New Issue
Block a user