Details
-
Bug
-
Status: Closed (View Workflow)
-
Minor
-
Resolution: Duplicate
-
10.9.0, 10.10.2
-
None
-
mac os monterey v12.1
Description
Step1: Create table
CREATE TABLE IF NOT EXISTS brands (
name VARCHAR(255) NOT NULL,
sold longtext CHARACTER SET utf8mb4 COLLATE utf8mb4_bin DEFAULT NULL
);
Step2: Insert values into table
INSERT INTO brands (name, sold)
VALUES
('test', '[
,
{"id":"1","name":"1","count":5000}]'),
('test2', '[
,
{"id":"1","name":"1","count":10000}]'),
('test3', '[
,
{"id":"1","name":"1","count":15000}]'),
('test4', '[
,
{"id":"1","name":"1","count":700}]');
Step3: Extract values using query
SELECT name, JSON_EXTRACT(sold, '$[*].count') as cnt FROM brands;
Output is incorrect when running V10.9 and above:
name | cnt |
---|---|
test | [5000, 5000] |
test | 10000 |
test | 15000 |
test | 700 |
Output is correct when running V10.8 and below:
name | cnt |
---|---|
test | [5000, 5000] |
test | [10000, 10000] |
test | [15000, 15000] |
test | [700, 700] |
Test fiddle here: https://dbfiddle.uk/0A5oD29V
Attachments
Issue Links
- duplicates
-
MDEV-30304 Json Range only affects first row of the result set
- Closed