Skip to content

Commit

Permalink
generic: fix column COLLATE not displayed
Browse files Browse the repository at this point in the history
  • Loading branch information
lustefaniak committed Oct 20, 2023
1 parent 83cb734 commit 6f4c4ec
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 0 deletions.
3 changes: 3 additions & 0 deletions src/ast/ddl.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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}")?;
}
Expand Down
5 changes: 5 additions & 0 deletions tests/sqlparser_common.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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\")");
}

0 comments on commit 6f4c4ec

Please sign in to comment.