diff --git a/ui/src/scenes/Editor/Ace/questdbMode.ts b/ui/src/scenes/Editor/Ace/questdbMode.ts index 5f9f94e08cbe23495b77f781855a44fbd1e56e8b..21bb7d908e0a887e50a041f4e8adac718c17b5c0 100644 --- a/ui/src/scenes/Editor/Ace/questdbMode.ts +++ b/ui/src/scenes/Editor/Ace/questdbMode.ts @@ -29,18 +29,160 @@ const { Mode: SqlMode } = ace.require("ace/mode/sql") as { Mode: unknown } const oop = ace.require("ace/lib/oop") as { inherits: (a: any, b: any) => void } const QuestDBHighlightRules = function (this: HighlightRules) { - const keywords = - "select|insert|update|delete|from|where|and|or|by|order|limit|as|case|when|else|end|type|left|right|join|on|outer|desc|asc|union|create|table|primary|key|if|foreign|not|references|default|null|inner|cross|natural|database|drop|grant|over|sample|partition|latest|NaN|with|rename|truncate|asof|copy|alter|into|values|index|add|column|then|distinct|show|tables|columns|group" - const builtinConstants = "true|false" - const builtinFunctions = - "avg|count|first|last|max|min|sum|ucase|lcase|mid|len|round|rank|now|format|coalesce|ifnull|isnull|nvl" - const dataTypes = - "int|date|string|symbol|float|double|binary|timestamp|long|long256" + const keywords = [ + "add", + "alter", + "and", + "as", + "asc", + "asof", + "by", + "cache", + "capacity", + "case", + "column", + "columns", + "copy", + "create", + "cross", + "database", + "default", + "delete", + "desc", + "distinct", + "drop", + "else", + "end", + "foreign", + "from", + "grant", + "group", + "if", + "index", + "inner", + "insert", + "into", + "join", + "key", + "latest", + "left", + "limit", + "nan", + "natural", + "nocache", + "not", + "null", + "on", + "or", + "order", + "outer", + "over", + "partition", + "primary", + "references", + "rename", + "right", + "sample", + "select", + "show", + "splice", + "table", + "tables", + "then", + "truncate", + "type", + "union", + "update", + "values", + "when", + "where", + "with", + ] + const builtinConstants = ["false", "true"] + const builtinFunctions = [ + "abs", + "all_tables", + "avg", + "coalesce", + "concat", + "count", + "dateadd", + "datediff", + "day", + "day_of_week", + "day_of_week_sunday_first", + "days_in_month", + "first", + "format", + "hour", + "ifnull", + "is_leap_year", + "isnull", + "ksum", + "last", + "lcase", + "len", + "length", + "long_sequence", + "max", + "micros", + "mid", + "millis", + "min", + "minute", + "month", + "now", + "nsum", + "nvl", + "rank", + "rnd_bin", + "rnd_boolean", + "rnd_byte", + "rnd_char", + "rnd_date", + "rnd_double", + "rnd_float", + "rnd_int", + "rnd_long", + "rnd_long256", + "rnd_short", + "rnd_str", + "rnd_symbol", + "rnd_timestamp", + "round", + "round_down", + "round_half_even", + "round_up", + "second", + "sum", + "sysdate", + "systimestamp", + "tables_columns", + "timestamp_sequence", + "to_date", + "to_str", + "to_timestamp", + "ucase", + "year", + ] + const dataTypes = [ + "binary", + "date", + "double", + "float", + "int", + "long", + "long256", + "short", + "string", + "symbol", + "timestamp", + ] const keywordMapper = this.createKeywordMapper( { - keyword: [keywords, builtinFunctions, builtinConstants, dataTypes].join( - "|", - ), + keyword: [keywords, builtinFunctions, builtinConstants, dataTypes] + .map((k) => k.join("|")) + .join("|"), }, "identifier", true,