@@ -61,6 +61,14 @@ run_test_match "bad_to_ref_errors" \
6161run_test_match " bad_single_arg_errors" \
6262 " SELECT count(*) FROM dolt_schema_diff('definitely_not_a_ref');" \
6363 " Error" " $DB "
64+ # A malformed range endpoint must name the unresolvable ref, not emit a
65+ # generic error, matching the two-arg form.
66+ run_test_match " bad_range_from_names_endpoint" \
67+ " SELECT count(*) FROM dolt_schema_diff('does-not-exist..HEAD');" \
68+ " from_ref 'does-not-exist' could not be resolved" " $DB "
69+ run_test_match " bad_range_to_names_endpoint" \
70+ " SELECT count(*) FROM dolt_schema_diff('HEAD..does-not-exist');" \
71+ " to_ref 'does-not-exist' could not be resolved" " $DB "
6472
6573rm -f " $DB "
6674
@@ -386,4 +394,26 @@ run_test_match "rebase_replay_u_to_stmt" \
386394
387395rm -f " $DB "
388396
397+ # WORKING / STAGED pseudo-refs must resolve like the other dolt_* surfaces.
398+ # Before the catalog-aware resolver fix, schema_diff only accepted commit refs,
399+ # so HEAD/WORKING (and HEAD..WORKING, HEAD/STAGED) errored with
400+ # "to_ref 'WORKING' could not be resolved".
401+ DB=/tmp/test_sd_working_$$ .db; rm -f " $DB "
402+ echo " CREATE TABLE t(id INTEGER PRIMARY KEY, v TEXT);
403+ INSERT INTO t VALUES(1,'a');
404+ SELECT dolt_commit('-A','-m','c1');" | $DOLTLITE " $DB " > /dev/null 2>&1
405+ echo " CREATE TABLE w(id INTEGER PRIMARY KEY, x TEXT);" | $DOLTLITE " $DB " > /dev/null 2>&1
406+
407+ run_test " working_count" " SELECT count(*) FROM dolt_schema_diff('HEAD','WORKING');" " 1" " $DB "
408+ run_test " working_to_name" " SELECT to_table_name FROM dolt_schema_diff('HEAD','WORKING');" " w" " $DB "
409+ run_test " working_from_empty" " SELECT length(from_table_name) FROM dolt_schema_diff('HEAD','WORKING');" " 0" " $DB "
410+ run_test " working_range_count" " SELECT count(*) FROM dolt_schema_diff('HEAD..WORKING');" " 1" " $DB "
411+ run_test " working_self_empty" " SELECT count(*) FROM dolt_schema_diff('WORKING','WORKING');" " 0" " $DB "
412+
413+ echo " SELECT dolt_add('-A');" | $DOLTLITE " $DB " > /dev/null 2>&1
414+ run_test " staged_count" " SELECT count(*) FROM dolt_schema_diff('HEAD','STAGED');" " 1" " $DB "
415+ run_test " staged_to_name" " SELECT to_table_name FROM dolt_schema_diff('HEAD','STAGED');" " w" " $DB "
416+
417+ rm -f " $DB "
418+
389419dltest_finish
0 commit comments