TestFormat_DDL_KeywordCase verifies that DDL formatter respects keyword casing options.
(t *testing.T)
| 175 | |
| 176 | // TestFormat_DDL_KeywordCase verifies that DDL formatter respects keyword casing options. |
| 177 | func TestFormat_DDL_KeywordCase(t *testing.T) { |
| 178 | sql := "DROP SEQUENCE myseq" |
| 179 | tree, err := gosqlx.ParseWithDialect(sql, keywords.DialectMariaDB) |
| 180 | if err != nil { |
| 181 | t.Fatalf("Parse error: %v", err) |
| 182 | } |
| 183 | stmt := tree.Statements[0].(*ast.DropSequenceStatement) |
| 184 | |
| 185 | upperOpts := ast.FormatOptions{KeywordCase: ast.KeywordUpper} |
| 186 | result := formatter.FormatStatement(stmt, upperOpts) |
| 187 | if !strings.Contains(result, "DROP SEQUENCE") { |
| 188 | t.Errorf("expected uppercase keywords, got: %q", result) |
| 189 | } |
| 190 | |
| 191 | lowerOpts := ast.FormatOptions{KeywordCase: ast.KeywordLower} |
| 192 | result = formatter.FormatStatement(stmt, lowerOpts) |
| 193 | if !strings.Contains(result, "drop sequence") { |
| 194 | t.Errorf("expected lowercase keywords, got: %q", result) |
| 195 | } |
| 196 | } |
nothing calls this directly
no test coverage detected