From 6f4c4ec78ea0c59f872b56db80eec233ef44bfe4 Mon Sep 17 00:00:00 2001 From: Lukasz Stefaniak Date: Wed, 4 Oct 2023 12:22:27 +0200 Subject: [PATCH] generic: fix column COLLATE not displayed --- src/ast/ddl.rs | 3 +++ tests/sqlparser_common.rs | 5 +++++ 2 files changed, 8 insertions(+) diff --git a/src/ast/ddl.rs b/src/ast/ddl.rs index a4640d557..f1575d979 100644 --- a/src/ast/ddl.rs +++ b/src/ast/ddl.rs @@ -517,6 +517,9 @@ pub struct ColumnDef { impl fmt::Display for ColumnDef { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { write!(f, "{} {}", self.name, self.data_type)?; + if let Some(collation) = &self.collation { + write!(f, " COLLATE {collation}")?; + } for option in &self.options { write!(f, " {option}")?; } diff --git a/tests/sqlparser_common.rs b/tests/sqlparser_common.rs index 1511aa76e..f32f63935 100644 --- a/tests/sqlparser_common.rs +++ b/tests/sqlparser_common.rs @@ -7625,3 +7625,8 @@ fn parse_create_type() { create_type ); } + +#[test] +fn parse_create_table_collate() { + pg_and_generic().verified_stmt("CREATE TABLE tbl (foo INT, bar TEXT COLLATE \"de_DE\")"); +}