Skip to content

Commit

Permalink
Don't quote strings in tabular mode (#1473)
Browse files Browse the repository at this point in the history
Tabular mode isn't really for precision, anyway. This is what postgres
does, and I think it looks better.
  • Loading branch information
msullivan authored Feb 13, 2025
1 parent 6983652 commit b6ef9f5
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 1 deletion.
6 changes: 6 additions & 0 deletions src/print/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -252,6 +252,12 @@ fn is_numeric(v: &Value) -> bool {

fn to_cell(prn: &mut Printer<&mut String>, v: &Option<Value>) -> table::Cell {
match v {
Some(Value::Str(s)) => {
let s = native::format_string(s, prn.expand_strings());
prn.const_string(&s[1..s.len() - 1])
.unwrap_exc()
.unwrap_infallible()
}
Some(vi) => vi.format(prn).unwrap_exc().unwrap_infallible(),
None => {}
};
Expand Down
2 changes: 1 addition & 1 deletion src/print/native.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ pub trait FormatExt {
fn format<F: Formatter>(&self, prn: &mut F) -> Result<F::Error>;
}

fn format_string(s: &str, expanded: bool) -> String {
pub fn format_string(s: &str, expanded: bool) -> String {
let mut buf = String::with_capacity(s.len() + 2);
buf.push('\'');
for c in s.chars() {
Expand Down

0 comments on commit b6ef9f5

Please sign in to comment.