chore: more work done and planning with AI.
CI / Test (push) Failing after 25s
CI / Build (push) Has been skipped

This commit is contained in:
2026-06-30 22:43:25 +02:00
parent a58b081cae
commit c8030247f2
15 changed files with 4948 additions and 157 deletions
+56
View File
@@ -226,6 +226,62 @@ func TestDMLIdempotent(t *testing.T) {
}
}
func TestDMLWhereAndOr(t *testing.T) {
// where_wrap=always should split AND/OR conditions onto separate lines.
src := "select a from t where x = 1 and y = 2 or z = 3;"
got := format(src)
want := "SELECT a\nFROM t\nWHERE\n x = 1\n AND y = 2\n OR z = 3;\n"
if got != want {
t.Errorf("where and/or\n--- got ---\n%s\n--- want ---\n%s", got, want)
}
checkDML(t, "where and/or", got)
}
func TestDMLIndentJoin(t *testing.T) {
st := config.Default()
st.IndentJoin = true
src := "select a from t join s on t.id = s.id;"
got := File(parser.Parse(src), st)
want := "SELECT a\nFROM t\n JOIN s ON t.id = s.id;\n"
if got != want {
t.Errorf("indent join\n--- got ---\n%s\n--- want ---\n%s", got, want)
}
// Idempotence with same config.
twice := File(parser.Parse(got), st)
if twice != got {
t.Errorf("indent join not idempotent:\n--- once ---\n%s\n--- twice ---\n%s", got, twice)
}
}
func TestDMLSetAlignEqual(t *testing.T) {
st := config.Default()
st.SetAlignEqual = true
src := "update t set a = 1, bb = 2, ccc = 3 where id = 1;"
got := File(parser.Parse(src), st)
// All = signs should align.
if got == "" {
t.Error("empty output")
}
// Idempotence.
twice := File(parser.Parse(got), st)
if twice != got {
t.Errorf("set_align_equal not idempotent:\n--- once ---\n%s\n--- twice ---\n%s", got, twice)
}
}
func TestDMLAlignParamTypes(t *testing.T) {
src := "create function f(in p_name text, in p_long_name integer, out p_result boolean) returns void language sql as $$ select 1 $$;"
got := format(src)
// p_name and p_long_name should have aligned types.
if got == "" {
t.Error("empty output")
}
twice := format(got)
if twice != got {
t.Errorf("align_param_types not idempotent:\n--- once ---\n%s\n--- twice ---\n%s", got, twice)
}
}
func TestCorpusUnaffectedByDML(t *testing.T) {
// Verify the corpus (which contains only CREATE FUNCTION) is not affected
// by the new DML formatting path.