Skip to content

Commit 8289406

Browse files
committed
tests for issue
1 parent d6bbc3f commit 8289406

File tree

1 file changed

+19
-0
lines changed

1 file changed

+19
-0
lines changed

src/test/java/net/sf/jsqlparser/statement/comment/CommentTest.java

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
import net.sf.jsqlparser.schema.Column;
1616
import net.sf.jsqlparser.schema.Table;
1717
import static net.sf.jsqlparser.test.TestUtils.assertSqlCanBeParsedAndDeparsed;
18+
import static org.assertj.core.api.Assertions.assertThat;
1819
import static org.junit.Assert.assertEquals;
1920
import org.junit.Test;
2021

@@ -73,4 +74,22 @@ public void testToString() {
7374
public void testCommentColumnDeparseIssue696() throws JSQLParserException {
7475
assertSqlCanBeParsedAndDeparsed("COMMENT ON COLUMN hotels.hotelid IS 'Primary key of the table'");
7576
}
77+
78+
@Test
79+
public void testCommentTableColumnDiffersIssue984() throws JSQLParserException {
80+
Comment comment = (Comment) CCJSqlParserUtil.parse("COMMENT ON COLUMN myTable.myColumn is 'Some comment'");
81+
assertThat(comment.getTable()).isNull();
82+
assertThat(comment.getColumn().getColumnName()).isEqualTo("myColumn");
83+
assertThat(comment.getColumn().getTable().getFullyQualifiedName()).isEqualTo("myTable");
84+
}
85+
86+
@Test
87+
public void testCommentTableColumnDiffersIssue984_2() throws JSQLParserException {
88+
Comment comment = (Comment) CCJSqlParserUtil.parse("COMMENT ON COLUMN mySchema.myTable.myColumn is 'Some comment'");
89+
assertThat(comment.getTable()).isNull();
90+
assertThat(comment.getColumn().getColumnName()).isEqualTo("myColumn");
91+
assertThat(comment.getColumn().getTable().getFullyQualifiedName()).isEqualTo("mySchema.myTable");
92+
assertThat(comment.getColumn().getTable().getName()).isEqualTo("myTable");
93+
assertThat(comment.getColumn().getTable().getSchemaName()).isEqualTo("mySchema");
94+
}
7695
}

0 commit comments

Comments
 (0)