-
Notifications
You must be signed in to change notification settings - Fork 325
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
执行json_object,结果返回字段顺序会改变,和mariadb,mysql数据库不一样 #68
Comments
mysqld测试结果 |
polardbx-optimizer\src\main\java\com\alibaba\polardbx\optimizer\core\function\calc\scalar\json\JsonObject.java
|
关于MySQL 对 json_object输出顺序的描述:https://dev.mysql.com/doc/refman/8.0/en/json.html#json-normalization
MySQL会对 JSON对象的key进行排序,但是不保证这个顺序在每个发行版都是一致的。 而PolarDB-X中调用了FastJson的接口,底层com.alibaba.fastjson.serializer.MapSerializer 是基于HashMap的遍历,这个同样也是不保证顺序的。 |
mysql> SELECT JSON_OBJECT('id', 123, 'name', 'polardb-x');
+---------------------------------------------+
| JSON_OBJECT('id', 123, 'name', 'polardb-x') |
+---------------------------------------------+
| {"name":"polardb-x","id":123} |
+---------------------------------------------+
1 row in set (0.00 sec)
mariadb数据库的结果为,这应该是和mysql数据库一样
MariaDB [(none)]> SELECT JSON_OBJECT('id', 123, 'name', 'polardb-x');
+---------------------------------------------+
| JSON_OBJECT('id', 123, 'name', 'polardb-x') |
+---------------------------------------------+
| {"id": 123, "name": "polardb-x"} |
+---------------------------------------------+
1 row in set (0.000 sec)
The text was updated successfully, but these errors were encountered: