dolthub / dolt

Dolt – Git for Data
Apache License 2.0
17.72k stars 503 forks source link

`\diff` doesn't handle decimal diffs. It just prints integers. #8133

Open timsehn opened 1 month ago

timsehn commented 1 month ago

Repro

schema_conflicts/main> alter table weights modify column weight float;
schema_conflicts/main*> update weights set weight=weight + 0.1;
Empty set (0.01 sec)

schema_conflicts/main*> \diff
diff --dolt a/weights b/weights
--- a/weights
+++ b/weights
 CREATE TABLE `weights` (
   `id` int NOT NULL,
-  `weight` int,
+  `weight` float,
   PRIMARY KEY (`id`)
 ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_bin;
+---+----+--------+
|   | id | weight |
+---+----+--------+
| < | 0  | 1      |
| > | 0  | 1      |
| < | 1  | 2      |
| > | 1  | 2      |
+---+----+--------+
schema_conflicts/main*> select * from weights;
+----+--------+
| id | weight |
+----+--------+
| 0  | 1.1    |
| 1  | 2.1    |
+----+--------+
2 rows in set (0.00 sec)

The dolt_diff_weights table displays the correct values:

schema_conflicts/main*> select * from dolt_diff_weights;
+-------+-----------+----------------------------------+-------------------------+---------+-------------+----------------------------------+-------------------------+-----------+
| to_id | to_weight | to_commit                        | to_commit_date          | from_id | from_weight | from_commit                      | from_commit_date        | diff_type |
+-------+-----------+----------------------------------+-------------------------+---------+-------------+----------------------------------+-------------------------+-----------+
| 0     | 1.1       | WORKING                          | NULL                    | 0       | 1           | g0r60aqn09igdcjt0o1gnm3gr0ch0rp2 | 2024-07-18 22:16:18.978 | modified  |
| 1     | 2.1       | WORKING                          | NULL                    | 1       | 2           | g0r60aqn09igdcjt0o1gnm3gr0ch0rp2 | 2024-07-18 22:16:18.978 | modified  |
| 0     | 1         | g0r60aqn09igdcjt0o1gnm3gr0ch0rp2 | 2024-07-18 22:16:18.978 | NULL    | NULL        | 2iatqm7utlpk57ri37s32o4s1vubrvd0 | 2024-07-18 22:06:40.744 | added     |
| 1     | 2         | g0r60aqn09igdcjt0o1gnm3gr0ch0rp2 | 2024-07-18 22:16:18.978 | NULL    | NULL        | 2iatqm7utlpk57ri37s32o4s1vubrvd0 | 2024-07-18 22:06:40.744 | added     |
+-------+-----------+----------------------------------+-------------------------+---------+-------------+----------------------------------+-------------------------+-----------+
4 rows in set (0.00 sec)
timsehn commented 1 month ago

Note, this is also a problem with the command line diff output:

$ dolt diff
diff --dolt a/weights b/weights
--- a/weights
+++ b/weights
 CREATE TABLE `weights` (
   `id` int NOT NULL,
-  `weight` int,
+  `weight` float,
   PRIMARY KEY (`id`)
 ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_bin;
+---+----+--------+
|   | id | weight |
+---+----+--------+
| < | 0  | 1      |
| > | 0  | 1      |
| < | 1  | 2      |
| > | 1  | 2      |
+---+----+--------+