Support staging new tables with dolt add -p#10591
Conversation
When using 'dolt add -p' to stage rows from a new table (one that exists in working but not in staging), the workspace table UPDATE mechanism previously failed with 'table not found' because GetTableWriter looked for the table in the staging root where it didn't exist yet. This change adds ensureTableExistsInStaging() which: 1. Checks if the table exists in staging (fast path - no-op) 2. If not, checks if it exists in working 3. If yes, creates an empty table in staging with the same schema 4. Updates the session state to reflect the new staging root The table is created empty (not copied with data) because 'dolt add -p' allows partial staging - each row selected by the user will be inserted individually into the staging table via the workspace table UPDATE. Also adds unit tests and BATS integration tests for the new functionality.
jycor
left a comment
There was a problem hiding this comment.
LGTM! Thanks for the contribution
jycor
left a comment
There was a problem hiding this comment.
Looks like there are some failing tests.
|
Hmmm, just got the email about the test failing again.
Not sure I understand why off the top of my head, unless the formatting is different somehow? I'll take a look in the morning if that's okay. |
|
Hmm... that should be right. It's possible it's something silly like a missing/extra space. The individual BATS statements can just be run the in the shell if that helps. |
Locally dolt will render bool values as true/false, so the remote-engine test fails because it shows 1/0. Additionally whitespace will probably also an issue. Outputting in a csv format should result in the same data to compare in both scenarios.
|
Should have fixed it. I didn't realise there was a different when using The previously failing tests are now working, but let me know if you want me to tidy anything up or change it to be another way.
|
jycor
left a comment
There was a problem hiding this comment.
Everything looks good. Thanks for the contribution!
When using 'dolt add -p' to stage rows from a new table (one that exists in working but not in staging), the workspace table UPDATE mechanism previously failed with 'table not found' because GetTableWriter looked for the table in the staging root where it didn't exist yet.
This change adds ensureTableExistsInStaging() which:
The table is created empty (not copied with data) because 'dolt add -p' allows partial staging - each row selected by the user will be inserted individually into the staging table via the workspace table UPDATE.
Also adds unit tests and BATS integration tests for the new functionality.
Example usage: https://gist.github.com/nullun/e88cb2dab9568c6612c98d415a4a2efd