Details
-
Bug
-
Status: Confirmed (View Workflow)
-
Major
-
Resolution: Unresolved
-
10.5.11, 10.6.3, 10.2, 10.3, 10.4, 10.5, 10.6
-
None
-
linux, docker
Description
With the following scenario, the JSON_OBJECT output is truncated of one characters per boolean field present.
CREATE DATABASE test_bug |
|
CREATE table one ( |
`id` int(10) unsigned NOT NULL, |
`some_column` int(10) unsigned NULL, |
PRIMARY KEY (`id`) |
)
|
|
INSERT INTO one (id, some_column) VALUES (1, NULL), (2, 42) |
|
CREATE table two ( |
`id` int(10) unsigned NOT NULL, |
`fk_one` int(10) unsigned NOT NULL, |
PRIMARY KEY (`id`) |
)
|
|
SELECT
|
one.id,
|
JSON_OBJECT(
|
'foo', true, |
'bar', 1 = 1, |
'nullable', one.some_column IS NULL, |
'quaz', (SELECT 1 < 0) |
) as obj |
FROM one |
LEFT JOIN two |
ON two.fk_one = one.id |
LEFT JOIN three |
ON 1 |
GROUP BY one.id |
Result
id|obj |
|
--+--------------------------------------------------------+
|
1|{"foo": true, "bar": true, "nullable": true, "quaz": fal|
|
2|{"foo": true, "bar": true, "nullable": false, "quaz": fa|
|
Expected
id|obj |
|
--+------------------------------------------------------------+
|
1|{"foo": true, "bar": true, "nullable": true, "quaz": false} |
|
2|{"foo": true, "bar": true, "nullable": false, "quaz": false}|
|
Observation
This problem is not triggered when you :
- Remove the join clause
- Remove the group by clause
- Remove the null column from the SELECT query ( one.some_column IS NULL )
But even when you do any of those changes, the column definition is still wrong ( VARCHAR(number), number being too low ), despite the result being recieved in full, .