datatypes icon indicating copy to clipboard operation
datatypes copied to clipboard

When json is stored in the database, it will change its location

Open Jiang-boyang opened this issue 3 years ago • 2 comments

GORM Playground Link

Print before deposit: {"type":"object","labelWidth":120,"displayType":"row","properties":{"b":{"title":"b","type":"array","widget":"multiSelect","description":"","required":true,"disabled":false,"readOnly":false,"items":{"type":"string"},"enum":[""'dev-01'"",""'dev-02'"",""'dev-03'""],"enumNames":["dev-01","dev-02","dev-03"],"props":{"showSearch":true,"filterOption":true,"optionFilterProp":"label"}},"a":{"title":"a","type":"string","widget":"select","description":"","required":false,"disabled":false,"readOnly":false,"api":"staff","enum":["a","b","c"],"enumNames":["早","中","晚"],"props":{"showSearch":true,"filterOption":true,"optionFilterProp":"label"}},"c":{"title":"ceshi","type":"string","widget":"select","required":false,"disabled":false,"readOnly":false,"api":"hostname","props":{"showSearch":true,"filterOption":true,"optionFilterProp":"label"}}}} After inserting into the database: {"type": "object", "labelWidth": 120, "properties": {"a": {"api": "staff", "enum": ["a", "b", "c"], "type": "string", "props": {"showSearch": true, "filterOption": true, "optionFilterProp": "label"}, "title": "a", "widget": "select", "disabled": false, "readOnly": false, "required": false, "enumNames": ["早", "中", "晚"], "description": ""}, "b": {"enum": [""'dev-01'"", ""'dev-02'"", ""'dev-03'""], "type": "array", "items": {"type": "string"}, "props": {"showSearch": true, "filterOption": true, "optionFilterProp": "label"}, "title": "b", "widget": "multiSelect", "disabled": false, "readOnly": false, "required": true, "enumNames": ["dev-01", "dev-02", "dev-03"], "description": ""}, "c": {"api": "hostname", "type": "string", "props": {"showSearch": true, "filterOption": true, "optionFilterProp": "label"}, "title": "ceshi", "widget": "select", "disabled": false, "readOnly": false, "required": false}}, "displayType": "row"} It looks like gorm made changes to the data structure before storing it in the database

https://github.com/go-gorm/playground/pull/1

Description

Jiang-boyang avatar Jul 01 '21 09:07 Jiang-boyang

That is, I hope that the fields in json are disordered, but after saving, they become ordered (according to a, b, c... or 1, 2, 3, 4...).

Jiang-boyang avatar Jul 01 '21 10:07 Jiang-boyang

Please note that if you use go maps they have no predicatable order.

timo-klarshift avatar Jul 11 '22 10:07 timo-klarshift