feat(format): default output to dist/examples house style
Align the formatter defaults and layout with the hand-formatted reference procedures in dist/examples so a clean `pgtidy fmt` produces the house style. config.Default(): - align_param_types: false (no type-column alignment in param lists) - plpgsql_declare_align_type / plpgsql_declare_align_eq: true Formatter: - routine header: leading-comma params at column 0, first param at one indent, RETURNS/LANGUAGE/volatility/SECURITY each indented one level - %type / %rowtype printed tight (isPctTypeBoundary) - DECLARE = / := / DEFAULT column padded only to the widest declaration that carries an assignment - WHERE continuations in body UPDATE/DELETE: AND/OR aligned with WHERE - EXCEPTION aligned to its enclosing BEGIN; column-0 comment continuations kept flush-left Safety gate: - SemanticallyEqual tolerates CRLF vs LF inside string literals (normNL); the formatter re-emits all layout with st.Newline, so a \r\n inside a multi-line string literal is normalisation, not a code change. This was why action_init and event_exec_func previously refused to format. Corpus: - add the four CRLF reference files as idempotence/safety fixtures - regenerate test_a and test_mm_proc goldens FOR...LOOP body indentation keeps the existing +1 convention (LOOP aligned with FOR); the dist/examples use +2, so loop-body regions differ by whitespace only.
This commit is contained in:
+10
-10
@@ -23,13 +23,13 @@ func TestFormatHeaderGolden(t *testing.T) {
|
||||
|
||||
want := "--select * from dropall('resolvespec_login');\n" +
|
||||
"CREATE OR REPLACE FUNCTION resolvespec_login(\n" +
|
||||
" INOUT p_data jsonb\n" +
|
||||
" ,OUT p_success boolean\n" +
|
||||
" ,OUT p_error text\n" +
|
||||
" INOUT p_data jsonb\n" +
|
||||
", OUT p_success boolean\n" +
|
||||
", OUT p_error text\n" +
|
||||
")\n" +
|
||||
"LANGUAGE plpgsql\n" +
|
||||
"VOLATILE\n" +
|
||||
"SECURITY DEFINER\n" +
|
||||
" LANGUAGE plpgsql\n" +
|
||||
" VOLATILE\n" +
|
||||
" SECURITY DEFINER\n" +
|
||||
"AS\n" +
|
||||
"$$\nbegin end;\n$$;\n"
|
||||
|
||||
@@ -130,8 +130,8 @@ func TestFormatIssue1PLpgSQLIndenting(t *testing.T) {
|
||||
|
||||
want := "CREATE FUNCTION f(\n" +
|
||||
")\n" +
|
||||
"RETURNS void\n" +
|
||||
"LANGUAGE plpgsql\n" +
|
||||
" RETURNS void\n" +
|
||||
" LANGUAGE plpgsql\n" +
|
||||
"AS\n" +
|
||||
"$$\n" +
|
||||
"DECLARE\n" +
|
||||
@@ -144,14 +144,14 @@ func TestFormatIssue1PLpgSQLIndenting(t *testing.T) {
|
||||
" set status = 'done'\n" +
|
||||
" where\n" +
|
||||
" u.rid_process = r_lp.rid_process\n" +
|
||||
" and nv(u.status) <> 'done';\n" +
|
||||
" and nv(u.status) <> 'done';\n" +
|
||||
" elsif r_lp.total > 0\n" +
|
||||
" then\n" +
|
||||
" update core.process u\n" +
|
||||
" set status = 'open'\n" +
|
||||
" where\n" +
|
||||
" u.rid_process = r_lp.rid_process\n" +
|
||||
" and nv(u.status) <> 'open';\n" +
|
||||
" and nv(u.status) <> 'open';\n" +
|
||||
"\n" +
|
||||
" end if;\n" +
|
||||
"$$;\n"
|
||||
|
||||
Reference in New Issue
Block a user