dolthub / dolt

Dolt – Git for Data
Apache License 2.0
17.58k stars 498 forks source link

Should be able to use "STAGED" as commits in `dolt_commit_diff_[tablename]` #7978

Closed tbantle22 closed 1 month ago

tbantle22 commented 2 months ago

I believe this used to work, but getting a diff between STAGED and WORKING using the dolt_commit_diff_[tablename] system table currently fails (dolt v1.39.3).

For example,

SELECT * FROM `dolt_commit_diff_tablename` WHERE `from_commit` = "STAGED" AND `to_commit` = "WORKING"

Returns the error

branch not found: STAGED
timsehn commented 2 months ago

It seems what is happening here is that we optimized queries to these system tables and are turning that from_commit and to_commit into branches and doing an optimized table build instead of a full table build to speed up the query. I bet what is happening is that there is not special case logic for STAGED and WORKING and probably other special names like HEAD or HEAD^.

tbantle22 commented 2 months ago

To clarify "WORKING" does work, just not "STAGED" and "HEAD"

jycor commented 1 month ago

Fix for this is merged to dolt main. STAGED should work the same way as WORKING when used in a filter clause in dolt_diff system tables. For HEAD, HEAD~, ..., I think we use hashof('HEAD').