File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -32,5 +32,8 @@ def nodes(self) -> List[Node]:
3232 return nodes
3333
3434 def __str__ (self ) -> str :
35+ if not self .lines :
36+ return ""
37+
3538 draft = [line .render_with_comments (self .line_length ) for line in self .lines ]
36- return "" .join (draft )
39+ return "" .join (draft ). rstrip ( " \n " ) + " \n "
Original file line number Diff line number Diff line change @@ -6,3 +6,10 @@ def test_whitespace_formatting(default_analyzer: Analyzer) -> None:
66 expected_string = "select 1\n from my_table\n where true\n "
77 q = default_analyzer .parse_query (source_string = source_string )
88 assert str (q ) == expected_string
9+
10+
11+ def test_only_comment_formatting (default_analyzer : Analyzer ) -> None :
12+ source_string = "-- a comment"
13+ expected_string = "-- a comment\n "
14+ q = default_analyzer .parse_query (source_string = source_string )
15+ assert str (q ) == expected_string
You can’t perform that action at this time.
0 commit comments