IN predicate ignores utf8mb4_unicode_ci for accent-insensitive comparisons
Summary
Dolt returns different results for a string equality predicate and its semantically equivalent single-element IN predicate when using utf8mb4_unicode_ci.
Under utf8mb4_unicode_ci, cafe and café should compare equal. In Dolt, the equality predicate matches the accented value, but the equivalent
single-element IN predicate silently filters it out.
This is a silent wrong-result issue.
Minimal Reproduction
CREATE DATABASE IF NOT EXISTS dolt_collation_in_repro
CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;
USE dolt_collation_in_repro;
DROP TABLE IF EXISTS t;
CREATE TABLE t (
id INT PRIMARY KEY,
label VARCHAR(96)
CHARACTER SET utf8mb4
COLLATE utf8mb4_unicode_ci NULL
) ENGINE=InnoDB;
INSERT INTO t VALUES
(1, CONVERT(X'636166C3A9' USING utf8mb4)),
(2, 'cafe'),
(3, ' Cafe ');
SELECT id
FROM t
WHERE LOWER(TRIM(label)) = 'cafe'
ORDER BY id;
SELECT id
FROM t
WHERE LOWER(TRIM(label)) IN ('cafe')
ORDER BY id;
SELECT id
FROM t
WHERE LOWER(TRIM(label)) = 'cafe'
OR LOWER(TRIM(label)) = 'cafe'
ORDER BY id;Expected Result
All three queries should return: 1 2 3 The first query and the single-element IN ('cafe') query are semantically equivalent for this non-NULL expression. Under utf8mb4_unicode_ci, cafe and café should compare equal.
Actual Result
On Dolt 2.3.2: The equality query returns: 1 2 3
The equivalent OR query also returns: 1 2 3
However, the single-element IN query returns only: 2 3 The row containing café is incorrectly omitted. The issue also occurs with a direct column comparison:
SELECT id
FROM t
WHERE label = 'cafe'
ORDER BY id;
SELECT id
FROM t
WHERE label IN ('cafe')
ORDER BY id;Dolt returns: label = 'cafe' -> 1, 2 label IN ('cafe') -> 2
The metadata reports the expected collation:
SELECT
COLLATION(label) AS label_collation,
COLLATION(LOWER(TRIM(label))) AS expression_collation
FROM t
LIMIT 1;Both expressions report utf8mb4_unicode_ci.
Cross-Database Results
| Database | Equality | Single-element IN |
|---|---|---|
| MySQL 8.0.46 | 1, 2, 3 | 1, 2, 3 |
| MySQL 8.4.7 | 1, 2, 3 | 1, 2, 3 |
| MariaDB 12.3.2 | 1, 2, 3 | 1, 2, 3 |
| Dolt 2.3.1 | 1, 2, 3 | 2, 3 |
| Dolt 2.3.2 | 1, 2, 3 | 2, 3 |
Environment
Dolt version: 2.3.1 and 2.3.2 SQL VERSION(): 8.0.31 Platform: Windows amd64 Reference MySQL versions: 8.0.46 and 8.4.7 Reference MariaDB version: 12.3.2
Source: dolthub/dolt