Using JSON_SET I have no problem updating simple JSON datatype, but with nested it just doesn't work.
How query supposed to look like with format like this:
{
"textures":[
{
"label":"test",
"types":{
"t_1":0,
"t_2":0
}
},
{
"label":"KEK",
"types":{
"t_1":0,
"t_2":0
}
}
],
"weapons":[
{
"name":"WW_SHT",
"ammo":0
},
{
"name":"WW_DSS",
"ammo":0
}
]
}
Some rows might be empty, some rows won't have "weapons" structure.
What I tried:
UPDATE `player` SET `info` = COALESCE(
JSON_MERGE(
`info`,
JSON_OBJECT('textures',
JSON_OBJECT('types',
JSON_OBJECT('t_1', '1', 't_2', '0')
)
)
),
JSON_INSERT(
JSON_OBJECT(),
'$.textures',
JSON_OBJECT('types',
JSON_OBJECT('t_1', '1', 't_2', '0')
)
)
);
I want to update t_1 to change value from 0 to 1