Skip to content

Commit ff841d1

Browse files
authored
fix(query): fix comment display (#17615)
* fix(query): fix comment display * update * update * update * update * update
1 parent 48c3263 commit ff841d1

File tree

17 files changed

+252
-205
lines changed

17 files changed

+252
-205
lines changed

Cargo.lock

Lines changed: 10 additions & 9 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -557,7 +557,7 @@ tracing-subscriber = { version = "0.3.17", features = ["env-filter", "json", "va
557557

558558
# Databend Integration Test
559559
quickcheck = "1.0"
560-
sqllogictest = "0.21.0"
560+
sqllogictest = "0.28.0"
561561

562562
[workspace.lints.rust]
563563
async_fn_in_trait = "allow"

src/query/ast/src/ast/statements/data_mask.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ use std::fmt::Formatter;
1818
use derive_visitor::Drive;
1919
use derive_visitor::DriveMut;
2020

21+
use crate::ast::quote::QuotedString;
2122
use crate::ast::CreateOption;
2223
use crate::ast::Expr;
2324
use crate::ast::TypeName;
@@ -68,7 +69,7 @@ impl Display for CreateDatamaskPolicyStmt {
6869
self.policy.return_type, self.policy.body
6970
)?;
7071
if let Some(comment) = &self.policy.comment {
71-
write!(f, " COMMENT = '{}'", comment)?;
72+
write!(f, " COMMENT = {}", QuotedString(comment, '\''))?;
7273
}
7374

7475
Ok(())

src/query/ast/src/ast/statements/dictionary.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ use derive_visitor::Drive;
2020
use derive_visitor::DriveMut;
2121

2222
use super::ShowLimit;
23+
use crate::ast::quote::QuotedString;
2324
use crate::ast::write_comma_separated_list;
2425
use crate::ast::write_dot_separated_list;
2526
use crate::ast::write_space_separated_string_map;
@@ -74,7 +75,7 @@ impl Display for CreateDictionaryStmt {
7475
write!(f, ")")?;
7576
write!(f, ")")?;
7677
if let Some(comment) = &self.comment {
77-
write!(f, "COMMENT '{comment}' ")?;
78+
write!(f, "COMMENT {} ", QuotedString(comment.clone(), '\''))?;
7879
}
7980
Ok(())
8081
}

src/query/ast/src/ast/statements/network_policy.rs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ use std::fmt::Formatter;
1818
use derive_visitor::Drive;
1919
use derive_visitor::DriveMut;
2020

21+
use crate::ast::quote::QuotedString;
2122
use crate::ast::CreateOption;
2223

2324
#[derive(Debug, Clone, PartialEq, Eq, Drive, DriveMut)]
@@ -59,7 +60,7 @@ impl Display for CreateNetworkPolicyStmt {
5960
write!(f, ")")?;
6061
}
6162
if let Some(comment) = &self.comment {
62-
write!(f, " COMMENT = '{}'", comment)?;
63+
write!(f, " COMMENT = {}", QuotedString(comment, '\''))?;
6364
}
6465

6566
Ok(())
@@ -104,7 +105,7 @@ impl Display for AlterNetworkPolicyStmt {
104105
write!(f, ")")?;
105106
}
106107
if let Some(comment) = &self.comment {
107-
write!(f, " COMMENT = '{}'", comment)?;
108+
write!(f, " COMMENT = {}", QuotedString(comment, '\''))?;
108109
}
109110

110111
Ok(())

src/query/ast/src/ast/statements/password_policy.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ use std::fmt::Formatter;
1818
use derive_visitor::Drive;
1919
use derive_visitor::DriveMut;
2020

21+
use crate::ast::quote::QuotedString;
2122
use crate::ast::CreateOption;
2223

2324
#[derive(Debug, Clone, PartialEq, Drive, DriveMut)]
@@ -145,7 +146,7 @@ impl Display for PasswordSetOptions {
145146
write!(f, " PASSWORD_HISTORY = {}", history)?;
146147
}
147148
if let Some(comment) = &self.comment {
148-
write!(f, " COMMENT = '{}'", comment)?;
149+
write!(f, " COMMENT = {}", QuotedString(comment, '\''))?;
149150
}
150151

151152
Ok(())

src/query/ast/src/ast/statements/sequence.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ use std::fmt::Formatter;
1818
use derive_visitor::Drive;
1919
use derive_visitor::DriveMut;
2020

21+
use crate::ast::quote::QuotedString;
2122
use crate::ast::CreateOption;
2223
use crate::ast::Identifier;
2324

@@ -40,7 +41,7 @@ impl Display for CreateSequenceStmt {
4041
}
4142
write!(f, " {}", self.sequence)?;
4243
if let Some(comment) = &self.comment {
43-
write!(f, " COMMENT = '{}'", comment)?;
44+
write!(f, " COMMENT = {}", QuotedString(comment, '\''))?;
4445
}
4546
Ok(())
4647
}

src/query/ast/src/ast/statements/stream.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ use std::fmt::Formatter;
1818
use derive_visitor::Drive;
1919
use derive_visitor::DriveMut;
2020

21+
use crate::ast::quote::QuotedString;
2122
use crate::ast::write_dot_separated_list;
2223
use crate::ast::CreateOption;
2324
use crate::ast::Identifier;
@@ -63,7 +64,7 @@ impl Display for CreateStreamStmt {
6364
write!(f, " APPEND_ONLY = false")?;
6465
}
6566
if let Some(comment) = &self.comment {
66-
write!(f, " COMMENT = '{}'", comment)?;
67+
write!(f, " COMMENT = {}", QuotedString(comment, '\''))?;
6768
}
6869
Ok(())
6970
}

src/query/ast/src/ast/statements/task.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ use std::fmt::Formatter;
1919
use derive_visitor::Drive;
2020
use derive_visitor::DriveMut;
2121

22+
use crate::ast::quote::QuotedString;
2223
use crate::ast::write_comma_separated_string_list;
2324
use crate::ast::write_comma_separated_string_map;
2425
use crate::ast::Expr;
@@ -298,7 +299,7 @@ impl Display for AlterTaskOptions {
298299
write!(f, " SUSPEND_TASK_AFTER_NUM_FAILURES = {num}")?;
299300
}
300301
if let Some(comments) = comments {
301-
write!(f, " COMMENT = '{comments}'")?;
302+
write!(f, " COMMENT = {}", QuotedString(comments, '\''))?;
302303
}
303304
if let Some(error_integration) = error_integration {
304305
write!(f, " ERROR_INTEGRATION = '{error_integration}'")?;

src/query/service/src/interpreters/interpreter_dictionary_show_create.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
use std::sync::Arc;
1616

1717
use databend_common_ast::ast::quote::display_ident;
18+
use databend_common_ast::ast::quote::QuotedString;
1819
use databend_common_ast::parser::Dialect;
1920
use databend_common_catalog::catalog::Catalog;
2021
use databend_common_exception::ErrorCode;
@@ -129,7 +130,7 @@ impl ShowCreateDictionaryInterpreter {
129130
// compatibility: creating table in the old planner will not have `fields_comments`
130131
let comment = field_comments
131132
.get(&field.column_id)
132-
.and_then(|c| format!(" COMMENT '{}'", c).into())
133+
.and_then(|c| format!(" COMMENT {}", QuotedString(c, '\'')).into())
133134
.unwrap_or_default();
134135

135136
let ident = display_ident(

0 commit comments

Comments
 (0)