dolthub / dolthub/dolt

DOLT_COMMIT_DIFF_table is missing data when there's a schema collation change merged in

Closed
#6,612 3 comments 0 reactions 1 assignee Claimed by @zachmu View on GitHub
bug customer issue merge version control
Dominant language
Go
Stars
24.4k
Forks
873
Avg merge
1d 8h
Merged PRs (30d)
120

Description

We have an unusual scenario where changing the collation of a column in `main` and merging it into `feature` makes the three dots diff miss the commits made on `feature` before the merge.

```
dolt sql -q "create table tableA (keyC varchar(255) not null, col1 varchar(255), PRIMARY KEY (keyC)) DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci"
dolt add .
dolt commit -m "new table"

dolt checkout -b feature
dolt sql -q "insert into tableA (keyC, col1) values ('1', 'test')"
dolt add .
dolt commit -m "new row in branch"

dolt checkout main
dolt sql -q "ALTER TABLE tableA COLLATE utf8mb4_0900_bin"
dolt sql -q "ALTER TABLE tableA MODIFY col1 VARCHAR(255) NOT NULL CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_bin"
dolt add .
dolt commit -m "change collation"

dolt checkout feature
```

At this point, if you run `dolt sql -q "select * from DOLT_COMMIT_DIFF_tableA where to_commit = HASHOF('feature') and from_commit = DOLT_MERGE_BASE('main', 'feature')"` you get:
```
+---------+---------+----------------------------------+-------------------------+-----------+-----------+----------------------------------+-------------------------+-----------+
| to_keyC | to_col1 | to_commit | to_commit_date | from_keyC | from_col1 | from_commit | from_commit_date | diff_type |
+---------+---------+----------------------------------+-------------------------+-----------+-----------+----------------------------------+-------------------------+-----------+
| 1 | test | 56lp7e8nqdocau9dmbhfs7391fj1nuki | 2023-09-04 20:01:58.485 | NULL | NULL | 7trtqiuevrfv6cht9recgtf449o3clhe | 2023-09-04 20:01:58.227 | added |
+---------+---------+----------------------------------+-------------------------+-----------+-----------+----------------------------------+-------------------------+-----------+
```

But if you proceed and merge main into that branch, you won't see the first commit in the diff anymore.
```
dolt merge main -m "merge main into feature"
dolt conflicts resolve --theirs tableA
dolt commit -m "merge main into feature"

dolt sql -q "insert into tableA (keyC, col1) values ('2', 'test 2')"
dolt add .
dolt commit -m "new row in branch"

dolt sql -q "select * from DOLT_COMMIT_DIFF_tableA where to_commit = HASHOF('feature') and from_commit = DOLT_MERGE_BASE('main', 'feature')"
```

```
+---------+---------+----------------------------------+-------------------------+-----------+-----------+----------------------------------+------------------------+-----------+
| to_keyC | to_col1 | to_commit | to_commit_date | from_keyC | from_col1 | from_commit | from_commit_date | diff_type |
+---------+---------+----------------------------------+-------------------------+-----------+-----------+----------------------------------+------------------------+-----------+
| 2 | test 2 | pmjsjgvh6javod0e4c9t8n9thns5ub7b | 2023-09-04 19:58:18.675 | NULL | NULL | d7q4tg8h9n4vdg9im59cc1ri6699f600 | 2023-09-04 19:56:16.91 | added |
+---------+---------+----------------------------------+-------------------------+-----------+-----------+----------------------------------+------------------------+-----------+
```

If you don't make the collation change on `main` and merge `main` it into `feature`, the DOLT_COMMIT_DIFF table returns the first and second rows that were added correctly. I'm not sure this is actually an issue as we did that collation change, but I needed to confirm.

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.