I have this table:
CREATE TABLE `foo` (
`user_id` varchar(255) NOT NULL,
`settings` json NOT NULL,
PRIMARY KEY (`user_id`),
UNIQUE KEY `IDX_5471ee230b9746dfb775d6c354` (`user_id`)
)
I want to make a query that upserts user_id and settings (which is JSON).
I currently have this query, it upsers user_id as expected but the problem is that it overwrites the json settings.
REPLACE INTO foo(user_id, settings)
VALUES (
'3',JSON_SET(
settings,
"$.topLevelField",
JSON_OBJECT('nestedField1', true,
'nestedField2', "01-01-2020")
)
);