Skip to content

Commit

Permalink
fix(parser): fix unparse of include columns (#18098) (#18101)
Browse files Browse the repository at this point in the history
Co-authored-by: stonepage <[email protected]>
  • Loading branch information
github-actions[bot] and st1page authored Aug 19, 2024
1 parent f1167ee commit 75ee7c2
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/sqlparser/src/ast/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1827,7 +1827,7 @@ impl fmt::Display for Statement {
if !include_column_options.is_empty() { // (Ident, Option<Ident>)
write!(f, "{}", display_comma_separated(
include_column_options.iter().map(|option_item: &IncludeOptionItem| {
format!("INCLUDE {}{}{}",
format!(" INCLUDE {}{}{}",
option_item.column_type,
if let Some(inner_field) = &option_item.inner_field {
format!(" {}", inner_field)
Expand Down
2 changes: 2 additions & 0 deletions src/sqlparser/tests/testdata/create.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,8 @@
^
- input: CREATE TABLE T ("FULL" INT) ON CONFLICT DO UPDATE IF NOT NULL
formatted_sql: CREATE TABLE T ("FULL" INT) ON CONFLICT DO UPDATE IF NOT NULL
- input: CREATE TABLE t (a int, b int, ts timestamptz as proctime(), primary key (a)) ON CONFLICT DO UPDATE IF NOT NULL INCLUDE timestamp AS ts_col WITH (connector = 'kafka', properties.bootstrap.server = '127.0.0.1:9092', topic = 'test_topic') FORMAT PLAIN ENCODE JSON
formatted_sql: CREATE TABLE t (a INT, b INT, ts timestamptz AS proctime(), PRIMARY KEY (a)) ON CONFLICT DO UPDATE IF NOT NULL INCLUDE timestamp AS ts_col WITH (connector = 'kafka', properties.bootstrap.server = '127.0.0.1:9092', topic = 'test_topic') FORMAT PLAIN ENCODE JSON
- input: CREATE USER user WITH SUPERUSER CREATEDB PASSWORD 'password'
formatted_sql: CREATE USER user WITH SUPERUSER CREATEDB PASSWORD 'password'
- input: CREATE SINK snk
Expand Down

0 comments on commit 75ee7c2

Please sign in to comment.