{
  "cases": [
    {
      "case": "filter first,  extract second",
      "plan": "SCAN things",
      "result": "ok: 1 rows",
      "sql": "SELECT id FROM things WHERE x = 100 AND json_extract(state_json,'$.carried_by')='av1'",
      "survived": true
    },
    {
      "case": "extract first, filter second",
      "plan": "SCAN things",
      "result": "OperationalError: malformed JSON",
      "sql": "SELECT id FROM things WHERE json_extract(state_json,'$.carried_by')='av1' AND x = 100",
      "survived": false
    },
    {
      "case": "extract first, filter second, index on x",
      "plan": "SEARCH things USING INDEX ix (x=?)",
      "result": "ok: 1 rows",
      "sql": "SELECT id FROM things WHERE json_extract(state_json,'$.carried_by')='av1' AND x = 100",
      "survived": true
    },
    {
      "case": "json_valid first,  extract second",
      "plan": "SCAN things",
      "result": "ok: 401 rows",
      "sql": "SELECT id FROM things WHERE json_valid(state_json) AND json_extract(state_json,'$.carried_by')='av1'",
      "survived": true
    },
    {
      "case": "extract first, json_valid second",
      "plan": "SCAN things",
      "result": "OperationalError: malformed JSON",
      "sql": "SELECT id FROM things WHERE json_extract(state_json,'$.carried_by')='av1' AND json_valid(state_json)",
      "survived": false
    },
    {
      "case": "OR, not AND",
      "plan": "SCAN things",
      "result": "OperationalError: malformed JSON",
      "sql": "SELECT id FROM things WHERE x = 100 OR json_extract(state_json,'$.carried_by')='av1'",
      "survived": false
    },
    {
      "case": "the extract in a subquery the outer query filters",
      "plan": "SCAN things",
      "result": "ok: 1 rows",
      "sql": "SELECT id FROM (SELECT id, json_extract(state_json,'$.carried_by') AS c FROM things WHERE x = 100) WHERE c = 'av1'",
      "survived": true
    },
    {
      "case": "UPDATE, filter first",
      "plan": "SCAN things",
      "result": "ok: 1 rows",
      "sql": "UPDATE things SET x = 7 WHERE x = 100 AND json_extract(state_json,'$.carried_by')='av1'",
      "survived": true
    },
    {
      "case": "UPDATE, extract first",
      "plan": "SCAN things",
      "result": "OperationalError: malformed JSON",
      "sql": "UPDATE things SET x = 7 WHERE json_extract(state_json,'$.carried_by')='av1' AND x = 100",
      "survived": false
    }
  ],
  "sqlite_version": "3.45.1"
}