-
Notifications
You must be signed in to change notification settings - Fork 5.9k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Incompatible implementation of jsonpath extraction #30352
Comments
In tidb the current extract implementation is the following code:
When the buf len is 1 and pathExprList = 1, It will not construct an array, which is not compatible with MySQL.
|
It is not exactly. If the buf len is 1 and pathExprList = 1, it will not construct an array if pathExpr does not contain asterisks in MYSQL. /* t */ drop table if exists t;
-- t >> 0 rows affected
/* t */ create table t (a varchar(100));
-- t >> 0 rows affected
/* t */ insert into t values ('{"labels":[{"name":"foo"}]}'),('{"labels":[{"name":"foo"},{"name":"bar"}]}');
-- t >> 2 rows affected
/* t */ select a->'$.labels[0].name' from t;
-- t >> +-----------------------+
-- t | a->'$.labels[0].name' |
-- t +-----------------------+
-- t | "foo" |
-- t | "foo" |
-- t +-----------------------+
/* t */ select a->'$.labels[1].name' from t;
-- t >> +-----------------------+
-- t | a->'$.labels[0].name' |
-- t +-----------------------+
-- t | NULL |
-- t | "bar" |
-- t +-----------------------+ |
Bug Report
Please answer these questions before submitting your issue. Thanks!
1. Minimal reproduce step (Required)
2. What did you expect to see? (Required)
3. What did you see instead (Required)
4. What is your TiDB version? (Required)
master (6475e89)
The text was updated successfully, but these errors were encountered: