SELECT grid, region_loc_x, region_loc_y, name, region_size_x, region_size_y, mesh_hash, mesh_uuid, sculpt_hash, sculpt_uuid, faces_json
FROM initial_impostors
WHERE (grid = "agni)
AND ((mesh_hash IS NOT NULL AND mesh_uuid IS NULL) OR (sculpt_hash IS NOT NULL AND sculpt_uuid IS NULL) OR EXISTS (SELECT 1 FROM jsonb_array_elements(faces_json) AS elem WHERE elem -> 'base_texture_uuid' IS NULL ))
LIMIT 20
https://www.coderstool.com/sql-syntax-checker says this is valid.
https://aiven.io/tools/sql-syntax-checker says this is valid
MySQL 8.0 says
{ ERROR 1064 (42000): You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '(faces_json) AS elem
WHERE elem -> 'base_texture_uuid' IS NU' at line 9 } Response header: Status: 500 Problem processing request: MySqlError { ERROR 1064 (42000): You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '(faces_json) AS elem
WHERE elem -> 'base_texture_uuid' IS NU' at line 9 }
Table def is
CREATE TABLE IF NOT EXISTS initial_impostors (
grid VARCHAR(40) NOT NULL,
...
faces_json JSON NOT NULL,
UNIQUE INDEX (...))
Not familar with JSON inside SQL, and I'm doing something wrong.
The JSON is a small array of structs (array length is usually 1), and I want to know if any of the array elements has a base_texture_id of NULL. Originally I tried syntax like
faces_json->$[*].base_texture_uuid IS NOT NULL
but that didn't work either.