Created
April 14, 2025 19:02
-
-
Save sgress454/3efafe2d673f4a581fc420c6d8d3505e to your computer and use it in GitHub Desktop.
node-sql-parser AST example
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| [ | |
| { | |
| "with": [ | |
| { | |
| "name": { | |
| "type": "default", | |
| "value": "extension_safety_hub_menu_notifications" | |
| }, | |
| "stmt": { | |
| "tableList": [ | |
| "select::null::file", | |
| "select::null::parse_json" | |
| ], | |
| "columnList": [ | |
| "select::parse_json::key", | |
| "select::parse_json::fullkey", | |
| "select::parse_json::path", | |
| "select::parse_json::value", | |
| "select::file::filename", | |
| "select::file::path", | |
| "select::file::btime", | |
| "select::null::path", | |
| "select::chrome_preferences::path", | |
| "select::null::fullkey" | |
| ], | |
| "ast": { | |
| "with": null, | |
| "type": "select", | |
| "options": null, | |
| "distinct": null, | |
| "columns": [ | |
| { | |
| "expr": { | |
| "type": "column_ref", | |
| "table": "parse_json", | |
| "column": "key", | |
| "collate": null | |
| }, | |
| "as": null | |
| }, | |
| { | |
| "expr": { | |
| "type": "column_ref", | |
| "table": "parse_json", | |
| "column": "fullkey", | |
| "collate": null | |
| }, | |
| "as": null | |
| }, | |
| { | |
| "expr": { | |
| "type": "column_ref", | |
| "table": "parse_json", | |
| "column": "path", | |
| "collate": null | |
| }, | |
| "as": null | |
| }, | |
| { | |
| "expr": { | |
| "type": "column_ref", | |
| "table": "parse_json", | |
| "column": "value", | |
| "collate": null | |
| }, | |
| "as": null | |
| } | |
| ], | |
| "from": [ | |
| { | |
| "expr": { | |
| "tableList": [ | |
| "select::null::file" | |
| ], | |
| "columnList": [ | |
| "select::parse_json::key", | |
| "select::parse_json::fullkey", | |
| "select::parse_json::path", | |
| "select::parse_json::value", | |
| "select::file::filename", | |
| "select::file::path", | |
| "select::file::btime", | |
| "select::null::path" | |
| ], | |
| "ast": { | |
| "with": null, | |
| "type": "select", | |
| "options": null, | |
| "distinct": null, | |
| "columns": [ | |
| { | |
| "expr": { | |
| "type": "column_ref", | |
| "table": "file", | |
| "column": "filename", | |
| "collate": null | |
| }, | |
| "as": null | |
| }, | |
| { | |
| "expr": { | |
| "type": "column_ref", | |
| "table": "file", | |
| "column": "path", | |
| "collate": null | |
| }, | |
| "as": null | |
| }, | |
| { | |
| "expr": { | |
| "type": "column_ref", | |
| "table": "file", | |
| "column": "btime", | |
| "collate": null | |
| }, | |
| "as": null | |
| } | |
| ], | |
| "from": [ | |
| { | |
| "db": null, | |
| "table": "file", | |
| "as": null | |
| } | |
| ], | |
| "where": { | |
| "type": "binary_expr", | |
| "operator": "LIKE", | |
| "left": { | |
| "type": "column_ref", | |
| "table": null, | |
| "column": "path", | |
| "collate": null | |
| }, | |
| "right": { | |
| "type": "double_quote_string", | |
| "value": "/Users/%/Library/Application Support/Google/Chrome/%/Preferences" | |
| } | |
| }, | |
| "groupby": null, | |
| "having": null, | |
| "orderby": [ | |
| { | |
| "expr": { | |
| "type": "column_ref", | |
| "table": "file", | |
| "column": "btime", | |
| "collate": null | |
| }, | |
| "type": "DESC" | |
| } | |
| ], | |
| "limit": { | |
| "seperator": "", | |
| "value": [ | |
| { | |
| "type": "number", | |
| "value": 20 | |
| } | |
| ] | |
| }, | |
| "for_update": null | |
| }, | |
| "parentheses": true | |
| }, | |
| "as": "chrome_preferences" | |
| }, | |
| { | |
| "db": null, | |
| "table": "parse_json", | |
| "as": null, | |
| "join": "INNER JOIN", | |
| "on": { | |
| "type": "binary_expr", | |
| "operator": "=", | |
| "left": { | |
| "type": "column_ref", | |
| "table": "chrome_preferences", | |
| "column": "path", | |
| "collate": null | |
| }, | |
| "right": { | |
| "type": "column_ref", | |
| "table": "parse_json", | |
| "column": "path", | |
| "collate": null | |
| } | |
| } | |
| } | |
| ], | |
| "where": { | |
| "type": "binary_expr", | |
| "operator": "AND", | |
| "left": { | |
| "type": "binary_expr", | |
| "operator": "LIKE", | |
| "left": { | |
| "type": "column_ref", | |
| "table": "parse_json", | |
| "column": "path", | |
| "collate": null | |
| }, | |
| "right": { | |
| "type": "double_quote_string", | |
| "value": "/Users/%/Library/Application Support/Google/Chrome/%/Preferences" | |
| } | |
| }, | |
| "right": { | |
| "type": "binary_expr", | |
| "operator": "OR", | |
| "left": { | |
| "type": "binary_expr", | |
| "operator": "IN", | |
| "left": { | |
| "type": "column_ref", | |
| "table": null, | |
| "column": "fullkey", | |
| "collate": null | |
| }, | |
| "right": { | |
| "type": "expr_list", | |
| "value": [ | |
| { | |
| "type": "double_quote_string", | |
| "value": "profile/name" | |
| }, | |
| { | |
| "type": "double_quote_string", | |
| "value": "profile/safety_hub_menu_notifications/extensions/isCurrentlyActive" | |
| }, | |
| { | |
| "type": "double_quote_string", | |
| "value": "profile/safety_hub_menu_notifications/extensions/result/timestamp" | |
| } | |
| ] | |
| } | |
| }, | |
| "right": { | |
| "type": "binary_expr", | |
| "operator": "LIKE", | |
| "left": { | |
| "type": "column_ref", | |
| "table": null, | |
| "column": "fullkey", | |
| "collate": null | |
| }, | |
| "right": { | |
| "type": "double_quote_string", | |
| "value": "profile/safety_hub_menu_notifications/extensions/result/triggeringExtensions%" | |
| } | |
| }, | |
| "parentheses": true | |
| } | |
| }, | |
| "groupby": null, | |
| "having": null, | |
| "orderby": null, | |
| "limit": null, | |
| "for_update": null | |
| } | |
| }, | |
| "columns": null | |
| }, | |
| { | |
| "name": { | |
| "type": "default", | |
| "value": "extension_details" | |
| }, | |
| "stmt": { | |
| "tableList": [ | |
| "select::null::file", | |
| "select::null::parse_json", | |
| "select::null::extension_safety_hub_menu_notifications" | |
| ], | |
| "columnList": [ | |
| "select::parse_json::key", | |
| "select::parse_json::fullkey", | |
| "select::parse_json::path", | |
| "select::parse_json::value", | |
| "select::file::filename", | |
| "select::file::path", | |
| "select::file::btime", | |
| "select::null::path", | |
| "select::chrome_preferences::path", | |
| "select::null::fullkey", | |
| "select::null::key", | |
| "select::null::value", | |
| "select::null::profile_name", | |
| "select::null::notification_active", | |
| "select::null::triggering_extension", | |
| "select::null::timestamp" | |
| ], | |
| "ast": { | |
| "with": null, | |
| "type": "select", | |
| "options": null, | |
| "distinct": null, | |
| "columns": [ | |
| { | |
| "expr": { | |
| "type": "column_ref", | |
| "table": null, | |
| "column": "path", | |
| "collate": null | |
| }, | |
| "as": null | |
| }, | |
| { | |
| "expr": { | |
| "type": "case", | |
| "expr": null, | |
| "args": [ | |
| { | |
| "type": "when", | |
| "cond": { | |
| "type": "binary_expr", | |
| "operator": "=", | |
| "left": { | |
| "type": "column_ref", | |
| "table": null, | |
| "column": "key", | |
| "collate": null | |
| }, | |
| "right": { | |
| "type": "single_quote_string", | |
| "value": "name" | |
| } | |
| }, | |
| "result": { | |
| "type": "column_ref", | |
| "table": null, | |
| "column": "value", | |
| "collate": null | |
| } | |
| } | |
| ] | |
| }, | |
| "as": "profile_name" | |
| }, | |
| { | |
| "expr": { | |
| "type": "case", | |
| "expr": null, | |
| "args": [ | |
| { | |
| "type": "when", | |
| "cond": { | |
| "type": "binary_expr", | |
| "operator": "=", | |
| "left": { | |
| "type": "column_ref", | |
| "table": null, | |
| "column": "key", | |
| "collate": null | |
| }, | |
| "right": { | |
| "type": "single_quote_string", | |
| "value": "isCurrentlyActive" | |
| } | |
| }, | |
| "result": { | |
| "type": "column_ref", | |
| "table": null, | |
| "column": "value", | |
| "collate": null | |
| } | |
| } | |
| ] | |
| }, | |
| "as": "notification_active" | |
| }, | |
| { | |
| "expr": { | |
| "type": "case", | |
| "expr": null, | |
| "args": [ | |
| { | |
| "type": "when", | |
| "cond": { | |
| "type": "binary_expr", | |
| "operator": "GLOB", | |
| "left": { | |
| "type": "column_ref", | |
| "table": null, | |
| "column": "key", | |
| "collate": null | |
| }, | |
| "right": { | |
| "type": "single_quote_string", | |
| "value": "*[0-9]" | |
| } | |
| }, | |
| "result": { | |
| "type": "column_ref", | |
| "table": null, | |
| "column": "value", | |
| "collate": null | |
| } | |
| } | |
| ] | |
| }, | |
| "as": "triggering_extension" | |
| }, | |
| { | |
| "expr": { | |
| "type": "case", | |
| "expr": null, | |
| "args": [ | |
| { | |
| "type": "when", | |
| "cond": { | |
| "type": "binary_expr", | |
| "operator": "=", | |
| "left": { | |
| "type": "column_ref", | |
| "table": null, | |
| "column": "key", | |
| "collate": null | |
| }, | |
| "right": { | |
| "type": "single_quote_string", | |
| "value": "timestamp" | |
| } | |
| }, | |
| "result": { | |
| "type": "column_ref", | |
| "table": null, | |
| "column": "value", | |
| "collate": null | |
| } | |
| } | |
| ] | |
| }, | |
| "as": "timestamp" | |
| } | |
| ], | |
| "from": [ | |
| { | |
| "db": null, | |
| "table": "extension_safety_hub_menu_notifications", | |
| "as": null | |
| } | |
| ], | |
| "where": null, | |
| "groupby": { | |
| "columns": [ | |
| { | |
| "type": "column_ref", | |
| "table": null, | |
| "column": "path", | |
| "collate": null | |
| }, | |
| { | |
| "type": "column_ref", | |
| "table": null, | |
| "column": "profile_name", | |
| "collate": null | |
| }, | |
| { | |
| "type": "column_ref", | |
| "table": null, | |
| "column": "notification_active", | |
| "collate": null | |
| }, | |
| { | |
| "type": "column_ref", | |
| "table": null, | |
| "column": "triggering_extension", | |
| "collate": null | |
| }, | |
| { | |
| "type": "column_ref", | |
| "table": null, | |
| "column": "timestamp", | |
| "collate": null | |
| } | |
| ] | |
| }, | |
| "having": null, | |
| "orderby": null, | |
| "limit": null, | |
| "for_update": null | |
| } | |
| }, | |
| "columns": null | |
| }, | |
| { | |
| "name": { | |
| "type": "default", | |
| "value": "problematic_extensions" | |
| }, | |
| "stmt": { | |
| "tableList": [ | |
| "select::null::file", | |
| "select::null::parse_json", | |
| "select::null::extension_safety_hub_menu_notifications", | |
| "select::null::extension_details" | |
| ], | |
| "columnList": [ | |
| "select::parse_json::key", | |
| "select::parse_json::fullkey", | |
| "select::parse_json::path", | |
| "select::parse_json::value", | |
| "select::file::filename", | |
| "select::file::path", | |
| "select::file::btime", | |
| "select::null::path", | |
| "select::chrome_preferences::path", | |
| "select::null::fullkey", | |
| "select::null::key", | |
| "select::null::value", | |
| "select::null::profile_name", | |
| "select::null::notification_active", | |
| "select::null::triggering_extension", | |
| "select::null::timestamp" | |
| ], | |
| "ast": { | |
| "with": null, | |
| "type": "select", | |
| "options": null, | |
| "distinct": null, | |
| "columns": [ | |
| { | |
| "expr": { | |
| "type": "column_ref", | |
| "table": null, | |
| "column": "path", | |
| "collate": null | |
| }, | |
| "as": null | |
| }, | |
| { | |
| "expr": { | |
| "type": "aggr_func", | |
| "name": "MAX", | |
| "args": { | |
| "expr": { | |
| "type": "column_ref", | |
| "table": null, | |
| "column": "profile_name", | |
| "collate": null | |
| } | |
| }, | |
| "over": { | |
| "partitionby": [ | |
| { | |
| "expr": { | |
| "type": "column_ref", | |
| "table": null, | |
| "column": "path", | |
| "collate": null | |
| }, | |
| "as": null | |
| } | |
| ], | |
| "orderby": null | |
| } | |
| }, | |
| "as": "profile_name" | |
| }, | |
| { | |
| "expr": { | |
| "type": "aggr_func", | |
| "name": "MAX", | |
| "args": { | |
| "expr": { | |
| "type": "column_ref", | |
| "table": null, | |
| "column": "notification_active", | |
| "collate": null | |
| } | |
| }, | |
| "over": null | |
| }, | |
| "as": "notification_active" | |
| }, | |
| { | |
| "expr": { | |
| "type": "aggr_func", | |
| "name": "MAX", | |
| "args": { | |
| "expr": { | |
| "type": "column_ref", | |
| "table": null, | |
| "column": "timestamp", | |
| "collate": null | |
| } | |
| }, | |
| "over": null | |
| }, | |
| "as": "timestamp" | |
| }, | |
| { | |
| "expr": { | |
| "type": "column_ref", | |
| "table": null, | |
| "column": "triggering_extension", | |
| "collate": null | |
| }, | |
| "as": null | |
| } | |
| ], | |
| "from": [ | |
| { | |
| "db": null, | |
| "table": "extension_details", | |
| "as": null | |
| } | |
| ], | |
| "where": null, | |
| "groupby": null, | |
| "having": null, | |
| "orderby": null, | |
| "limit": null, | |
| "for_update": null | |
| } | |
| }, | |
| "columns": null | |
| } | |
| ], | |
| "type": "select", | |
| "options": null, | |
| "distinct": null, | |
| "columns": [ | |
| { | |
| "expr": { | |
| "type": "column_ref", | |
| "table": null, | |
| "column": "path", | |
| "collate": null | |
| }, | |
| "as": null | |
| }, | |
| { | |
| "expr": { | |
| "type": "column_ref", | |
| "table": null, | |
| "column": "profile_name", | |
| "collate": null | |
| }, | |
| "as": null | |
| }, | |
| { | |
| "expr": { | |
| "type": "column_ref", | |
| "table": null, | |
| "column": "notification_active", | |
| "collate": null | |
| }, | |
| "as": null | |
| }, | |
| { | |
| "expr": { | |
| "type": "column_ref", | |
| "table": null, | |
| "column": "timestamp", | |
| "collate": null | |
| }, | |
| "as": null | |
| }, | |
| { | |
| "expr": { | |
| "type": "column_ref", | |
| "table": null, | |
| "column": "triggering_extension", | |
| "collate": null | |
| }, | |
| "as": null | |
| } | |
| ], | |
| "from": [ | |
| { | |
| "db": null, | |
| "table": "problematic_extensions", | |
| "as": null | |
| } | |
| ], | |
| "where": { | |
| "type": "binary_expr", | |
| "operator": "IS NOT", | |
| "left": { | |
| "type": "column_ref", | |
| "table": null, | |
| "column": "triggering_extension", | |
| "collate": null | |
| }, | |
| "right": { | |
| "type": "null", | |
| "value": null | |
| } | |
| }, | |
| "groupby": null, | |
| "having": null, | |
| "orderby": null, | |
| "limit": null, | |
| "for_update": null | |
| } | |
| ] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment