node-sql-parser
Version:
simple node sql parser
1 lines • 297 kB
JavaScript
!function(t,e){if("object"==typeof exports&&"object"==typeof module)module.exports=e();else if("function"==typeof define&&define.amd)define([],e);else{var r=e();for(var n in r)("object"==typeof exports?exports:t)[n]=r[n]}}(this,(function(){return function(t){var e={};function r(n){if(e[n])return e[n].exports;var o=e[n]={i:n,l:!1,exports:{}};return t[n].call(o.exports,o,o.exports,r),o.l=!0,o.exports}return r.m=t,r.c=e,r.d=function(t,e,n){r.o(t,e)||Object.defineProperty(t,e,{enumerable:!0,get:n})},r.r=function(t){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})},r.t=function(t,e){if(1&e&&(t=r(t)),8&e)return t;if(4&e&&"object"==typeof t&&t&&t.__esModule)return t;var n=Object.create(null);if(r.r(n),Object.defineProperty(n,"default",{enumerable:!0,value:t}),2&e&&"string"!=typeof t)for(var o in t)r.d(n,o,function(e){return t[e]}.bind(null,o));return n},r.n=function(t){var e=t&&t.__esModule?function(){return t.default}:function(){return t};return r.d(e,"a",e),e},r.o=function(t,e){return Object.prototype.hasOwnProperty.call(t,e)},r.p="",r(r.s=27)}([function(t,e,r){"use strict";r.r(e),r.d(e,"arrayStructTypeToSQL",(function(){return E})),r.d(e,"autoIncrementToSQL",(function(){return _})),r.d(e,"columnOrderListToSQL",(function(){return x})),r.d(e,"commonKeywordArgsToSQL",(function(){return U})),r.d(e,"commonOptionConnector",(function(){return i})),r.d(e,"connector",(function(){return c})),r.d(e,"commonTypeValue",(function(){return O})),r.d(e,"commentToSQL",(function(){return A})),r.d(e,"createBinaryExpr",(function(){return f})),r.d(e,"createValueExpr",(function(){return l})),r.d(e,"dataTypeToSQL",(function(){return g})),r.d(e,"DEFAULT_OPT",(function(){return u})),r.d(e,"escape",(function(){return p})),r.d(e,"literalToSQL",(function(){return j})),r.d(e,"columnIdentifierToSql",(function(){return h})),r.d(e,"getParserOpt",(function(){return b})),r.d(e,"identifierToSql",(function(){return y})),r.d(e,"onPartitionsToSQL",(function(){return C})),r.d(e,"replaceParams",(function(){return L})),r.d(e,"returningToSQL",(function(){return S})),r.d(e,"hasVal",(function(){return w})),r.d(e,"setParserOpt",(function(){return v})),r.d(e,"toUpper",(function(){return m})),r.d(e,"topToSQL",(function(){return d})),r.d(e,"triggerEventToSQL",(function(){return T}));var n=r(2),o=r(12);function a(t){return(a="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t})(t)}var u={database:"snowflake",type:"table",trimQuery:!0,parseOptions:{includeLocations:!1}},s=u;function i(t,e,r){if(r)return t?"".concat(t.toUpperCase()," ").concat(e(r)):e(r)}function c(t,e){if(e)return"".concat(t.toUpperCase()," ").concat(e)}function l(t){var e=a(t);if(Array.isArray(t))return{type:"expr_list",value:t.map(l)};if(null===t)return{type:"null",value:null};switch(e){case"boolean":return{type:"bool",value:t};case"string":return{type:"string",value:t};case"number":return{type:"number",value:t};default:throw new Error('Cannot convert value "'.concat(e,'" to SQL'))}}function f(t,e,r){var n={operator:t,type:"binary_expr"};return n.left=e.type?e:l(e),"BETWEEN"===t||"NOT BETWEEN"===t?(n.right={type:"expr_list",value:[l(r[0]),l(r[1])]},n):(n.right=r.type?r:l(r),n)}function p(t){return t}function b(){return s}function v(t){s=t}function d(t){if(t){var e=t.value,r=t.percent,n=t.parentheses?"(".concat(e,")"):e,o="TOP ".concat(n);return r?"".concat(o," ").concat(r.toUpperCase()):o}}function h(t){var e=b().database;if(t)switch(e&&e.toLowerCase()){case"athena":case"db2":case"postgresql":case"redshift":case"snowflake":case"noql":case"trino":case"sqlite":return'"'.concat(t,'"');case"transactsql":return"[".concat(t,"]");case"mysql":case"mariadb":case"bigquery":default:return"`".concat(t,"`")}}function y(t,e,r){if(!0===e)return"'".concat(t,"'");if(t){if("*"===t)return t;if(r)return"".concat(r).concat(t).concat(r);var n=b().database;switch(n&&n.toLowerCase()){case"mysql":case"mariadb":return"`".concat(t,"`");case"athena":case"postgresql":case"redshift":case"snowflake":case"trino":case"noql":case"sqlite":return'"'.concat(t,'"');case"transactsql":return"[".concat(t,"]");case"bigquery":case"db2":return t;default:return"`".concat(t,"`")}}}function m(t){if(t)return t.toUpperCase()}function w(t){return t}function j(t){if(t){var e=t.prefix,r=t.type,n=t.parentheses,u=t.suffix,s=t.value,i="object"===a(t)?s:t;switch(r){case"backticks_quote_string":i="`".concat(s,"`");break;case"string":i="'".concat(s,"'");break;case"regex_string":i='r"'.concat(s,'"');break;case"hex_string":i="X'".concat(s,"'");break;case"full_hex_string":i="0x".concat(s);break;case"natural_string":i="N'".concat(s,"'");break;case"bit_string":i="b'".concat(s,"'");break;case"double_quote_string":i='"'.concat(s,'"');break;case"single_quote_string":i="'".concat(s,"'");break;case"boolean":case"bool":i=s?"TRUE":"FALSE";break;case"null":i="NULL";break;case"star":i="*";break;case"param":i="".concat(e||":").concat(s),e=null;break;case"origin":i=s.toUpperCase();break;case"date":case"datetime":case"time":case"timestamp":i="".concat(r.toUpperCase()," '").concat(s,"'");break;case"var_string":i="N'".concat(s,"'");break;case"unicode_string":i="U&'".concat(s,"'")}var c=[];return e&&c.push(m(e)),c.push(i),u&&("string"==typeof u&&c.push(u),"object"===a(u)&&(u.collate?c.push(Object(o.a)(u.collate)):c.push(j(u)))),i=c.join(" "),n?"(".concat(i,")"):i}}function O(t){if(!t)return[];var e=t.type,r=t.symbol,n=t.value;return[e.toUpperCase(),r,"string"==typeof n?n.toUpperCase():j(n)].filter(w)}function L(t,e){return function t(e,r){return Object.keys(e).filter((function(t){var r=e[t];return Array.isArray(r)||"object"===a(r)&&null!==r})).forEach((function(n){var o=e[n];if("object"!==a(o)||"param"!==o.type)return t(o,r);if(void 0===r[o.value])throw new Error("no value for parameter :".concat(o.value," found"));return e[n]=l(r[o.value]),null})),e}(JSON.parse(JSON.stringify(t)),e)}function C(t){var e=t.type,r=t.partitions;return[m(e),"(".concat(r.map((function(t){if("range"!==t.type)return j(t);var e=t.start,r=t.end,n=t.symbol;return"".concat(j(e)," ").concat(m(n)," ").concat(j(r))})).join(", "),")")].join(" ")}function g(t){var e=t.schema,r=t.dataType,n=t.length,o=t.parentheses,a=t.scale,u=t.suffix,s="";null!=n&&(s=a?"".concat(n,", ").concat(a):n),o&&(s="(".concat(s,")")),u&&u.length&&(s+=" ".concat(u.join(" ")));var i=e?"".concat(e,"."):"";return"".concat(i).concat(r).concat(s)}function E(t){if(t){var e=t.dataType,r=t.definition,n=t.anglebracket,o=m(e);if("ARRAY"!==o&&"STRUCT"!==o)return o;var a=r&&r.map((function(t){return[t.field_name,E(t.field_type)].filter(w).join(" ")})).join(", ");return n?"".concat(o,"<").concat(a,">"):"".concat(o," ").concat(a)}}function A(t){if(t){var e=[],r=t.keyword,n=t.symbol,o=t.value;return e.push(r.toUpperCase()),n&&e.push(n),e.push(j(o)),e.join(" ")}}function T(t){return t.map((function(t){var e=t.keyword,r=t.args,o=[m(e)];if(r){var a=r.keyword,u=r.columns;o.push(m(a),u.map(n.f).join(", "))}return o.join(" ")})).join(" OR ")}function S(t){return t?["RETURNING",t.columns.map(n.h).filter(w).join(", ")].join(" "):""}function U(t){return t?[m(t.keyword),m(t.args)]:[]}function _(t){if(t){if("string"==typeof t){var e=b().database;switch(e&&e.toLowerCase()){case"sqlite":return"AUTOINCREMENT";default:return"AUTO_INCREMENT"}}var r=t.keyword,n=t.seed,o=t.increment,a=t.parentheses,u=m(r);return a&&(u+="(".concat(j(n),", ").concat(j(o),")")),u}}function x(t){if(t)return t.map(n.e).filter(w).join(", ")}},function(t,e,r){"use strict";r.d(e,"a",(function(){return E})),r.d(e,"b",(function(){return A})),r.d(e,"d",(function(){return g})),r.d(e,"c",(function(){return T}));var n=r(0),o=r(9),a=r(15);var u=r(23),s=r(21);var i=r(12),c=r(2),l=r(6),f=r(10),p=r(18);var b=r(13),v=r(24);function d(t){return(d="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t})(t)}function h(t){var e=t.expr_list,r=t.type;switch(Object(n.toUpper)(r)){case"STRUCT":case"ROW":return"(".concat(Object(c.i)(e),")");case"ARRAY":return function(t){var e=t.array_path,r=t.brackets,o=t.expr_list,a=t.parentheses;if(!o)return"[".concat(Object(c.i)(e),"]");var u=Array.isArray(o)?o.map((function(t){return"(".concat(Object(c.i)(t),")")})).filter(n.hasVal).join(", "):E(o);return r?"[".concat(u,"]"):a?"(".concat(u,")"):u}(t);default:return""}}function y(t){var e=t.definition,r=t.keyword,o=[Object(n.toUpper)(r)];return e&&"object"===d(e)&&(o.length=0,o.push(Object(n.arrayStructTypeToSQL)(e))),o.push(h(t)),o.filter(n.hasVal).join("")}var m=r(22),w=r(3),j=r(5),O=r(20);function L(t){return(L="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t})(t)}var C={alter:o.b,aggr_func:function(t){var e=t.args,r=t.filter,o=t.over,u=t.within_group_orderby,s=E(e.expr);s=Array.isArray(s)?s.join(", "):s;var i=t.name,c=Object(a.a)(o);e.distinct&&(s=["DISTINCT",s].join(" ")),e.separator&&e.separator.delimiter&&(s=[s,Object(n.literalToSQL)(e.separator.delimiter)].join("".concat(e.separator.symbol," "))),e.separator&&e.separator.expr&&(s=[s,E(e.separator.expr)].join(" ")),e.orderby&&(s=[s,T(e.orderby,"order by")].join(" ")),e.separator&&e.separator.value&&(s=[s,Object(n.toUpper)(e.separator.keyword),Object(n.literalToSQL)(e.separator.value)].filter(n.hasVal).join(" "));var l=u?"WITHIN GROUP (".concat(T(u,"order by"),")"):"",f=r?"FILTER (WHERE ".concat(E(r.where),")"):"";return["".concat(i,"(").concat(s,")"),l,c,f].filter(n.hasVal).join(" ")},any_value:l.a,window_func:O.c,array:y,assign:u.a,binary_expr:s.a,case:function(t){var e=["CASE"],r=t.args,n=t.expr,o=t.parentheses;n&&e.push(E(n));for(var a=0,u=r.length;a<u;++a)e.push(r[a].type.toUpperCase()),r[a].cond&&(e.push(E(r[a].cond)),e.push("THEN")),e.push(E(r[a].result));return e.push("END"),o?"(".concat(e.join(" "),")"):e.join(" ")},cast:l.c,collate:i.a,column_ref:c.f,column_definition:c.c,datatype:n.dataTypeToSQL,extract:l.d,flatten:l.e,fulltext_search:c.j,function:l.g,lambda:l.i,load_data:m.a,insert:j.b,interval:p.a,json:function(t){var e=t.keyword,r=t.expr_list;return[Object(n.toUpper)(e),r.map((function(t){return E(t)})).join(", ")].join(" ")},json_object_arg:l.h,json_visitor:function(t){return[t.symbol,E(t.expr)].join("")},func_arg:l.f,show:v.a,struct:y,tablefunc:l.j,tables:w.c,unnest:w.d,values:f.c,window:O.b};function g(t){var e=t.prefix,r=void 0===e?"@":e,o=t.name,a=t.members,u=t.quoted,s=t.suffix,i=[],c=a&&a.length>0?"".concat(o,".").concat(a.join(".")):o,l="".concat(r||"").concat(c);return s&&(l+=s),i.push(l),[u,i.join(" "),u].filter(n.hasVal).join("")}function E(t){if(t){var e=t;if(t.ast){var r=e.ast;Reflect.deleteProperty(e,r);for(var o=0,a=Object.keys(r);o<a.length;o++){var u=a[o];e[u]=r[u]}}var s=e.type;return"expr"===s?E(e.expr):C[s]?C[s](e):Object(n.literalToSQL)(e)}}function A(t){return t?(Array.isArray(t)||(t=[t]),t.map(E)):[]}function T(t,e){if(!Array.isArray(t))return"";var r=[],o=Object(n.toUpper)(e);switch(o){case"ORDER BY":r=t.map((function(t){return[E(t.expr),t.type||"ASC",Object(n.toUpper)(t.nulls)].filter(n.hasVal).join(" ")}));break;case"PARTITION BY":default:r=t.map((function(t){return E(t.expr)}))}return Object(n.connector)(o,r.join(", "))}C.var=g,C.expr_list=function(t){var e=A(t.value),r=t.parentheses,n=t.separator;if(!r&&!n)return e;var o=n||", ",a=e.join(o);return r?"(".concat(a,")"):a},C.select=function(t){var e="object"===L(t._next)?Object(j.b)(t):Object(b.a)(t);return t.parentheses?"(".concat(e,")"):e},C.unary_expr=function(t){var e=t.operator,r=t.parentheses,n=t.expr,o="-"===e||"+"===e||"~"===e||"!"===e?"":" ",a="".concat(e).concat(o).concat(E(n));return r?"(".concat(a,")"):a},C.map_object=function(t){var e=t.keyword,r=t.expr.map((function(t){return[Object(n.literalToSQL)(t.key),Object(n.literalToSQL)(t.value)].join(", ")})).join(", ");return[Object(n.toUpper)(e),"[".concat(r,"]")].join("")}},function(t,e,r){"use strict";r.d(e,"a",(function(){return v})),r.d(e,"c",(function(){return j})),r.d(e,"f",(function(){return d})),r.d(e,"h",(function(){return C})),r.d(e,"i",(function(){return E})),r.d(e,"b",(function(){return h})),r.d(e,"d",(function(){return b})),r.d(e,"e",(function(){return w})),r.d(e,"g",(function(){return y})),r.d(e,"j",(function(){return L})),r.d(e,"k",(function(){return g}));var n=r(12),o=r(19),a=r(1),u=r(6),s=r(3),i=r(0);function c(t){return(c="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t})(t)}function l(t){return function(t){if(Array.isArray(t))return p(t)}(t)||function(t){if("undefined"!=typeof Symbol&&null!=t[Symbol.iterator]||null!=t["@@iterator"])return Array.from(t)}(t)||f(t)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function f(t,e){if(t){if("string"==typeof t)return p(t,e);var r={}.toString.call(t).slice(8,-1);return"Object"===r&&t.constructor&&(r=t.constructor.name),"Map"===r||"Set"===r?Array.from(t):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?p(t,e):void 0}}function p(t,e){(null==e||e>t.length)&&(e=t.length);for(var r=0,n=Array(e);r<e;r++)n[r]=t[r];return n}function b(t,e){if("string"==typeof t)return Object(i.identifierToSql)(t,e);var r=t.expr,n=t.offset,o=t.suffix,u=n&&n.map((function(t){return["[",t.name,"".concat(t.name?"(":""),Object(i.literalToSQL)(t.value),"".concat(t.name?")":""),"]"].filter(i.hasVal).join("")})).join("");return[Object(a.a)(r),u,o].filter(i.hasVal).join("")}function v(t){if(!t||0===t.length)return"";var e,r=[],n=function(t,e){var r="undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(!r){if(Array.isArray(t)||(r=f(t))||e&&t&&"number"==typeof t.length){r&&(t=r);var n=0,o=function(){};return{s:o,n:function(){return n>=t.length?{done:!0}:{done:!1,value:t[n++]}},e:function(t){throw t},f:o}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var a,u=!0,s=!1;return{s:function(){r=r.call(t)},n:function(){var t=r.next();return u=t.done,t},e:function(t){s=!0,a=t},f:function(){try{u||null==r.return||r.return()}finally{if(s)throw a}}}}(t);try{for(n.s();!(e=n.n()).done;){var o=e.value,u=o.brackets?"[".concat(Object(a.a)(o.index),"]"):"".concat(o.notation).concat(Object(a.a)(o.index));o.property&&(u="".concat(u,".").concat(Object(i.literalToSQL)(o.property))),r.push(u)}}catch(t){n.e(t)}finally{n.f()}return r.join("")}function d(t){var e=t.array_index,r=t.as,o=t.column,u=t.collate,s=t.db,c=t.isDual,f=t.notations,p=void 0===f?[]:f,d=t.options,h=t.schema,y=t.table,m=t.parentheses,w=t.suffix,j=t.order_by,O=t.subFields,L=void 0===O?[]:O,C="*"===o?"*":b(o,c),g=[s,h,y].filter(i.hasVal).map((function(t){return"".concat("string"==typeof t?Object(i.identifierToSql)(t):Object(a.a)(t))})),E=g[0];if(E){for(var A=1;A<g.length;++A)E="".concat(E).concat(p[A]||".").concat(g[A]);C="".concat(E).concat(p[A]||".").concat(C)}var T=[C=["".concat(C).concat(v(e))].concat(l(L)).join("."),Object(n.a)(u),Object(a.a)(d),Object(i.commonOptionConnector)("AS",a.a,r)];T.push("string"==typeof w?Object(i.toUpper)(w):Object(a.a)(w)),T.push(Object(i.toUpper)(j));var S=T.filter(i.hasVal).join(" ");return m?"(".concat(S,")"):S}function h(t){if(t){var e=t.schema,r=t.dataType,n=t.length,o=t.suffix,s=t.scale,c=t.expr,l=null!=n,f=Object(i.dataTypeToSQL)({schema:e,dataType:r,length:n,suffix:o,scale:s,parentheses:l});if(c&&(f+=Object(a.a)(c)),t.array){var p=Object(u.b)(t);f+=[/^\[.*\]$/.test(p)?"":" ",p].join("")}return f}}function y(t){var e=[];if(!t)return e;var r=t.definition,n=t.keyword,o=t.match,u=t.table,c=t.on_action;return e.push(Object(i.toUpper)(n)),e.push(Object(s.c)(u)),e.push(r&&"(".concat(r.map((function(t){return Object(a.a)(t)})).join(", "),")")),e.push(Object(i.toUpper)(o)),c.map((function(t){return e.push(Object(i.toUpper)(t.type),Object(a.a)(t.value))})),e.filter(i.hasVal)}function m(t){var e=[],r=t.nullable,n=t.character_set,u=t.check,s=t.comment,c=t.constraint,f=t.collate,p=t.storage,b=t.using,v=t.default_val,d=t.generated,h=t.auto_increment,m=t.unique,w=t.primary_key,j=t.column_format,O=t.reference_definition,L=t.generated_by_default,C=[Object(i.toUpper)(r&&r.action),Object(i.toUpper)(r&&r.value)].filter(i.hasVal).join(" ");if(d||e.push(C),v){var g=v.type,E=v.value;e.push(g.toUpperCase(),Object(a.a)(E))}var A=Object(i.getParserOpt)().database;return c&&e.push(Object(i.toUpper)(c.keyword),Object(i.literalToSQL)(c.constraint)),e.push(Object(o.a)(u)),e.push(function(t){if(t)return[Object(i.toUpper)(t.value),"(".concat(Object(a.a)(t.expr),")"),Object(i.toUpper)(t.storage_type)].filter(i.hasVal).join(" ")}(d)),d&&e.push(C),e.push(Object(i.autoIncrementToSQL)(h),Object(i.toUpper)(w),Object(i.toUpper)(m),Object(i.literalToSQL)(L),Object(i.commentToSQL)(s)),e.push.apply(e,l(Object(i.commonTypeValue)(n))),"sqlite"!==A.toLowerCase()&&e.push(Object(a.a)(f)),e.push.apply(e,l(Object(i.commonTypeValue)(j))),e.push.apply(e,l(Object(i.commonTypeValue)(p))),e.push.apply(e,l(y(O))),e.push(Object(i.commonOptionConnector)("USING",a.a,b)),e.filter(i.hasVal).join(" ")}function w(t){var e=t.column,r=t.collate,n=t.nulls,o=t.opclass,u=t.order_by,s="string"==typeof e?{type:"column_ref",table:t.table,column:e}:t;return s.collate=null,[Object(a.a)(s),Object(a.a)(r),o,Object(i.toUpper)(u),Object(i.toUpper)(n)].filter(i.hasVal).join(" ")}function j(t){var e=[],r=d(t.column),n=h(t.definition);return e.push(r),e.push(n),e.push(m(t)),e.filter(i.hasVal).join(" ")}function O(t){return t?"object"===c(t)?["AS",Object(a.a)(t)].join(" "):["AS",/^(`?)[a-z_][0-9a-z_]*(`?)$/i.test(t)?Object(i.identifierToSql)(t):Object(i.columnIdentifierToSql)(t)].join(" "):""}function L(t){var e=t.against,r=t.as,n=t.columns,o=t.match,u=t.mode;return[[Object(i.toUpper)(o),"(".concat(n.map((function(t){return d(t)})).join(", "),")")].join(" "),[Object(i.toUpper)(e),["(",Object(a.a)(t.expr),u&&" ".concat(Object(i.literalToSQL)(u)),")"].filter(i.hasVal).join("")].join(" "),O(r)].filter(i.hasVal).join(" ")}function C(t,e){var r=t.expr,n=t.type;if("cast"===n)return Object(u.c)(t);e&&(r.isDual=e);var o=Object(a.a)(r),s=t.expr_list;if(s){var c=[o],l=s.map((function(t){return C(t,e)})).join(", ");return c.push([Object(i.toUpper)(n),n&&"(",l,n&&")"].filter(i.hasVal).join("")),c.filter(i.hasVal).join(" ")}return r.parentheses&&Reflect.has(r,"array_index")&&"cast"!==r.type&&(o="(".concat(o,")")),r.array_index&&"column_ref"!==r.type&&"function"!==r.type&&(o="".concat(o).concat(v(r.array_index))),[o,O(t.as)].filter(i.hasVal).join(" ")}function g(t){var e=Array.isArray(t)&&t[0];return!(!e||"dual"!==e.type)}function E(t,e){if(!t||"*"===t)return t;var r=g(e);return t.map((function(t){return C(t,r)})).join(", ")}},function(t,e,r){"use strict";r.d(e,"c",(function(){return y})),r.d(e,"a",(function(){return m})),r.d(e,"b",(function(){return h})),r.d(e,"d",(function(){return f}));var n=r(21),o=r(2),a=r(1),u=r(10),s=r(18),i=r(0);function c(t){return function(t){if(Array.isArray(t))return l(t)}(t)||function(t){if("undefined"!=typeof Symbol&&null!=t[Symbol.iterator]||null!=t["@@iterator"])return Array.from(t)}(t)||function(t,e){if(t){if("string"==typeof t)return l(t,e);var r={}.toString.call(t).slice(8,-1);return"Object"===r&&t.constructor&&(r=t.constructor.name),"Map"===r||"Set"===r?Array.from(t):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?l(t,e):void 0}}(t)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function l(t,e){(null==e||e>t.length)&&(e=t.length);for(var r=0,n=Array(e);r<e;r++)n[r]=t[r];return n}function f(t){var e=t.type,r=t.as,n=t.expr,o=t.with_offset;return["".concat(Object(i.toUpper)(e),"(").concat(n&&Object(a.a)(n)||"",")"),Object(i.commonOptionConnector)("AS","string"==typeof r?i.identifierToSql:a.a,r),Object(i.commonOptionConnector)(Object(i.toUpper)(o&&o.keyword),i.identifierToSql,o&&o.as)].filter(i.hasVal).join(" ")}function p(t){if(t)switch(t.type){case"pivot":case"unpivot":return function(t){var e=t.as,r=t.column,u=t.expr,s=t.in_expr,c=t.type,l=[Object(a.a)(u),"FOR",Object(o.f)(r),Object(n.a)(s)],f=["".concat(Object(i.toUpper)(c),"(").concat(l.join(" "),")")];return e&&f.push("AS",Object(i.identifierToSql)(e)),f.join(" ")}(t);default:return""}}function b(t){if(t){var e=t.keyword,r=t.expr,n=t.index,o=t.index_columns,u=t.parentheses,s=t.prefix,c=[];switch(e.toLowerCase()){case"forceseek":c.push(Object(i.toUpper)(e),"(".concat(Object(i.identifierToSql)(n)),"(".concat(o.map(a.a).filter(i.hasVal).join(", "),"))"));break;case"spatial_window_max_cells":c.push(Object(i.toUpper)(e),"=",Object(a.a)(r));break;case"index":c.push(Object(i.toUpper)(s),Object(i.toUpper)(e),u?"(".concat(r.map((function(t){return Object(i.identifierToSql)(t)})).join(", "),")"):"= ".concat(Object(i.identifierToSql)(r)));break;default:c.push(Object(a.a)(r))}return c.filter(i.hasVal).join(" ")}}function v(t,e){var r=t.name,n=t.symbol;return[Object(i.toUpper)(r),n,e].filter(i.hasVal).join(" ")}function d(t){var e=[];switch(t.keyword){case"as":e.push("AS","OF",Object(a.a)(t.of));break;case"from_to":e.push("FROM",Object(a.a)(t.from),"TO",Object(a.a)(t.to));break;case"between_and":e.push("BETWEEN",Object(a.a)(t.between),"AND",Object(a.a)(t.and));break;case"contained":e.push("CONTAINED","IN",Object(a.a)(t.in))}return e.filter(i.hasVal).join(" ")}function h(t){if("UNNEST"===Object(i.toUpper)(t.type))return f(t);var e,r,n,c,l=t.table,h=t.db,y=t.as,m=t.expr,w=t.operator,j=t.prefix,O=t.schema,L=t.server,C=t.suffix,g=t.tablesample,E=t.temporal_table,A=t.table_hint,T=t.surround,S=void 0===T?{}:T,U=Object(i.identifierToSql)(L,!1,S.server),_=Object(i.identifierToSql)(h,!1,S.db),x=Object(i.identifierToSql)(O,!1,S.schema),I=l&&Object(i.identifierToSql)(l,!1,S.table);if(m)switch(m.type){case"values":var N=m.parentheses,R=m.values,k=m.prefix,V=[N&&"(","",N&&")"],M=Object(u.c)(R);k&&(M=M.split("(").slice(1).map((function(t){return"".concat(Object(i.toUpper)(k),"(").concat(t)})).join("")),V[1]="VALUES ".concat(M),I=V.filter(i.hasVal).join("");break;case"tumble":I=function(t){if(!t)return"";var e=t.data,r=t.timecol,n=t.offset,a=t.size,u=[Object(i.identifierToSql)(e.expr.db),Object(i.identifierToSql)(e.expr.schema),Object(i.identifierToSql)(e.expr.table)].filter(i.hasVal).join("."),c="DESCRIPTOR(".concat(Object(o.f)(r.expr),")"),l=["TABLE(TUMBLE(TABLE ".concat(v(e,u)),v(r,c)],f=v(a,Object(s.a)(a.expr));return n&&n.expr?l.push(f,"".concat(v(n,Object(s.a)(n.expr)),"))")):l.push("".concat(f,"))")),l.filter(i.hasVal).join(", ")}(m);break;case"generator":r=(e=m).keyword,n=e.type,c=e.generators.map((function(t){return Object(i.commonTypeValue)(t).join(" ")})).join(", "),I="".concat(Object(i.toUpper)(r),"(").concat(Object(i.toUpper)(n),"(").concat(c,"))");break;default:I=Object(a.a)(m)}var q=[[U,_,x,I=[Object(i.toUpper)(j),I,Object(i.toUpper)(C)].filter(i.hasVal).join(" ")].filter(i.hasVal).join(".")];if(g){var P=["TABLESAMPLE",Object(a.a)(g.expr),Object(i.literalToSQL)(g.repeatable)].filter(i.hasVal).join(" ");q.push(P)}q.push(function(t){if(t){var e=t.keyword,r=t.expr;return[Object(i.toUpper)(e),d(r)].filter(i.hasVal).join(" ")}}(E),Object(i.commonOptionConnector)("AS","string"==typeof y?i.identifierToSql:a.a,y),p(w)),A&&q.push(Object(i.toUpper)(A.keyword),"(".concat(A.expr.map(b).filter(i.hasVal).join(", "),")"));var D=q.filter(i.hasVal).join(" ");return t.parentheses?"(".concat(D,")"):D}function y(t){if(!t)return"";if(!Array.isArray(t)){var e=t.expr,r=t.parentheses,n=t.joins,o=y(e);if(r){for(var u=[],s=[],l=!0===r?1:r.length,f=0;f++<l;)u.push("("),s.push(")");var p=n&&n.length>0?y([""].concat(c(n))):"";return u.join("")+o+s.join("")+p}return o}var b=t[0],v=[];if("dual"===b.type)return"DUAL";v.push(h(b));for(var d=1;d<t.length;++d){var m=t[d],w=m.on,j=m.using,O=m.join,L=[],C=Array.isArray(m)||Object.hasOwnProperty.call(m,"joins");L.push(O?" ".concat(Object(i.toUpper)(O)):","),L.push(C?y(m):h(m)),L.push(Object(i.commonOptionConnector)("ON",a.a,w)),j&&L.push("USING (".concat(j.map(i.literalToSQL).join(", "),")")),v.push(L.filter(i.hasVal).join(" "))}return v.filter(i.hasVal).join("")}function m(t){var e=t.keyword,r=t.symbol,n=t.value,o=[e.toUpperCase()];r&&o.push(r);var u=Object(i.literalToSQL)(n);switch(e){case"partition by":case"default collate":u=Object(a.a)(n);break;case"options":u="(".concat(n.map((function(t){return[t.keyword,t.symbol,Object(a.a)(t.value)].join(" ")})).join(", "),")");break;case"cluster by":u=n.map(a.a).join(", ")}return o.push(u),o.filter(i.hasVal).join(" ")}},function(t,e,r){"use strict";r.d(e,"a",(function(){return v})),r.d(e,"b",(function(){return d})),r.d(e,"c",(function(){return g})),r.d(e,"d",(function(){return E})),r.d(e,"e",(function(){return h})),r.d(e,"f",(function(){return y})),r.d(e,"g",(function(){return m})),r.d(e,"h",(function(){return S})),r.d(e,"i",(function(){return T})),r.d(e,"j",(function(){return A})),r.d(e,"l",(function(){return w})),r.d(e,"m",(function(){return j})),r.d(e,"o",(function(){return O})),r.d(e,"n",(function(){return L})),r.d(e,"k",(function(){return C}));var n=r(2),o=r(14),a=r(0),u=r(1),s=r(3),i=r(17),c=r(5);function l(t,e){var r="undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(!r){if(Array.isArray(t)||(r=p(t))||e&&t&&"number"==typeof t.length){r&&(t=r);var n=0,o=function(){};return{s:o,n:function(){return n>=t.length?{done:!0}:{done:!1,value:t[n++]}},e:function(t){throw t},f:o}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var a,u=!0,s=!1;return{s:function(){r=r.call(t)},n:function(){var t=r.next();return u=t.done,t},e:function(t){s=!0,a=t},f:function(){try{u||null==r.return||r.return()}finally{if(s)throw a}}}}function f(t){return function(t){if(Array.isArray(t))return b(t)}(t)||function(t){if("undefined"!=typeof Symbol&&null!=t[Symbol.iterator]||null!=t["@@iterator"])return Array.from(t)}(t)||p(t)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function p(t,e){if(t){if("string"==typeof t)return b(t,e);var r={}.toString.call(t).slice(8,-1);return"Object"===r&&t.constructor&&(r=t.constructor.name),"Map"===r||"Set"===r?Array.from(t):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?b(t,e):void 0}}function b(t,e){(null==e||e>t.length)&&(e=t.length);for(var r=0,n=Array(e);r<e;r++)n[r]=t[r];return n}function v(t){var e=Object(u.a)(t.expr);return"".concat("CALL"," ").concat(e)}function d(t){var e=t.type,r=t.keyword,o=t.name,i=t.prefix,c=t.suffix,l=[Object(a.toUpper)(e),Object(a.toUpper)(r),Object(a.toUpper)(i)];switch(r){case"table":l.push(Object(s.c)(o));break;case"trigger":l.push([o[0].schema?"".concat(Object(a.identifierToSql)(o[0].schema),"."):"",Object(a.identifierToSql)(o[0].trigger)].filter(a.hasVal).join(""));break;case"database":case"schema":case"procedure":l.push(Object(a.identifierToSql)(o));break;case"view":l.push(Object(s.c)(o),t.options&&t.options.map(u.a).filter(a.hasVal).join(" "));break;case"index":l.push.apply(l,[Object(n.f)(o)].concat(f(t.table?["ON",Object(s.b)(t.table)]:[]),[t.options&&t.options.map(u.a).filter(a.hasVal).join(" ")]));break;case"type":l.push(o.map(n.f).join(", "),t.options&&t.options.map(u.a).filter(a.hasVal).join(" "))}return c&&l.push(c.map(u.a).filter(a.hasVal).join(" ")),l.filter(a.hasVal).join(" ")}function h(t){var e=t.type,r=t.table,n=Object(a.toUpper)(e);return"".concat(n," ").concat(Object(a.identifierToSql)(r))}function y(t){var e=t.type,r=t.name,n=t.args,o=[Object(a.toUpper)(e)],s=[r];return n&&s.push("(".concat(Object(u.a)(n).join(", "),")")),o.push(s.join("")),o.filter(a.hasVal).join(" ")}function m(t){var e=t.type,r=t.label,n=t.target,o=t.query,u=t.stmts;return[r,Object(a.toUpper)(e),n,"IN",Object(c.a)([o]),"LOOP",Object(c.a)(u),"END LOOP",r].filter(a.hasVal).join(" ")}function w(t){var e=t.type,r=t.level,n=t.raise,o=t.using,s=[Object(a.toUpper)(e),Object(a.toUpper)(r)];return n&&s.push([Object(a.literalToSQL)(n.keyword),"format"===n.type&&n.expr.length>0&&","].filter(a.hasVal).join(""),n.expr.map((function(t){return Object(u.a)(t)})).join(", ")),o&&s.push(Object(a.toUpper)(o.type),Object(a.toUpper)(o.option),o.symbol,o.expr.map((function(t){return Object(u.a)(t)})).join(", ")),s.filter(a.hasVal).join(" ")}function j(t){var e=t.type,r=t.table,n=[],o="".concat(e&&e.toUpperCase()," TABLE");if(r){var a,u=l(r);try{for(u.s();!(a=u.n()).done;){var i=a.value.map(s.b);n.push(i.join(" TO "))}}catch(t){u.e(t)}finally{u.f()}}return"".concat(o," ").concat(n.join(", "))}function O(t){var e=t.type,r=t.db,n=Object(a.toUpper)(e),o=Object(a.identifierToSql)(r);return"".concat(n," ").concat(o)}function L(t){var e=t.type,r=t.expr,n=t.keyword,o=Object(a.toUpper)(e),s=r.map(u.a).join(", ");return[o,Object(a.toUpper)(n),s].filter(a.hasVal).join(" ")}function C(t){var e=t.type,r=t.keyword,n=t.tables,o=[e.toUpperCase(),Object(a.toUpper)(r)];if("UNLOCK"===e.toUpperCase())return o.join(" ");var u,i=[],c=l(n);try{var p=function(){var t=u.value,e=t.table,r=t.lock_type,n=[Object(s.b)(e)];if(r){n.push(["prefix","type","suffix"].map((function(t){return Object(a.toUpper)(r[t])})).filter(a.hasVal).join(" "))}i.push(n.join(" "))};for(c.s();!(u=c.n()).done;)p()}catch(t){c.e(t)}finally{c.f()}return o.push.apply(o,[i.join(", ")].concat(f(function(t){var e=t.lock_mode,r=t.nowait,n=[];if(e){var o=e.mode;n.push(o.toUpperCase())}return r&&n.push(r.toUpperCase()),n}(t)))),o.filter(a.hasVal).join(" ")}function g(t){var e=t.type,r=t.keyword,n=t.expr;return[Object(a.toUpper)(e),Object(a.toUpper)(r),Object(u.a)(n)].filter(a.hasVal).join(" ")}function E(t){var e=t.type,r=t.declare,s=t.symbol,i=[Object(a.toUpper)(e)],c=r.map((function(t){var e=t.at,r=t.name,s=t.as,i=t.constant,c=t.datatype,l=t.not_null,f=t.prefix,p=t.definition,b=t.keyword,v=[[e,r].filter(a.hasVal).join(""),Object(a.toUpper)(s),Object(a.toUpper)(i)];switch(b){case"variable":v.push(Object(n.b)(c),Object(u.a)(t.collate),Object(a.toUpper)(l)),p&&v.push(Object(a.toUpper)(p.keyword),Object(u.a)(p.value));break;case"cursor":v.push(Object(a.toUpper)(f));break;case"table":v.push(Object(a.toUpper)(f),"(".concat(p.map(o.a).join(", "),")"))}return v.filter(a.hasVal).join(" ")})).join("".concat(s," "));return i.push(c),i.join(" ")}function A(t){var e=t.boolean_expr,r=t.else_expr,n=t.elseif_expr,o=t.if_expr,s=t.prefix,c=t.go,l=t.semicolons,f=t.suffix,p=t.type,b=[Object(a.toUpper)(p),Object(u.a)(e),Object(a.literalToSQL)(s),"".concat(Object(i.a)(o.ast||o)).concat(l[0]),Object(a.toUpper)(c)];return n&&b.push(n.map((function(t){return[Object(a.toUpper)(t.type),Object(u.a)(t.boolean_expr),"THEN",Object(i.a)(t.then.ast||t.then),t.semicolon].filter(a.hasVal).join(" ")})).join(" ")),r&&b.push("ELSE","".concat(Object(i.a)(r.ast||r)).concat(l[1])),b.push(Object(a.literalToSQL)(f)),b.filter(a.hasVal).join(" ")}function T(t){var e=t.name,r=t.host,n=[Object(a.literalToSQL)(e)];return r&&n.push("@",Object(a.literalToSQL)(r)),n.join("")}function S(t){var e=t.type,r=t.grant_option_for,o=t.keyword,s=t.objects,i=t.on,c=t.to_from,l=t.user_or_roles,f=t.with,p=[Object(a.toUpper)(e),Object(a.literalToSQL)(r)],b=s.map((function(t){var e=t.priv,r=t.columns,o=[Object(u.a)(e)];return r&&o.push("(".concat(r.map(n.f).join(", "),")")),o.join(" ")})).join(", ");if(p.push(b),i)switch(p.push("ON"),o){case"priv":p.push(Object(a.literalToSQL)(i.object_type),i.priv_level.map((function(t){return[Object(a.identifierToSql)(t.prefix),Object(a.identifierToSql)(t.name)].filter(a.hasVal).join(".")})).join(", "));break;case"proxy":p.push(T(i))}return p.push(Object(a.toUpper)(c),l.map(T).join(", ")),p.push(Object(a.literalToSQL)(f)),p.filter(a.hasVal).join(" ")}},function(t,e,r){"use strict";r.d(e,"b",(function(){return L})),r.d(e,"a",(function(){return C}));var n=r(9),o=r(1),a=r(3),u=r(0);var s=r(14),i=r(2);function c(t){var e=t.name,r=t.type;switch(r){case"table":case"view":var n=[Object(u.identifierToSql)(e.db),Object(u.identifierToSql)(e.table)].filter(u.hasVal).join(".");return"".concat(Object(u.toUpper)(r)," ").concat(n);case"column":return"COLUMN ".concat(Object(i.f)(e));default:return"".concat(Object(u.toUpper)(r)," ").concat(Object(u.literalToSQL)(e))}}function l(t){var e=t.keyword,r=t.expr;return[Object(u.toUpper)(e),Object(u.literalToSQL)(r)].filter(u.hasVal).join(" ")}var f=r(13);var p=r(7),b=r(16);var v=r(8),d=r(10),h=r(4);function y(t){var e=t.name,r=t.value;return["@".concat(e),"=",Object(o.a)(r)].filter(u.hasVal).join(" ")}var m=r(22),w=r(23);var j=r(24),O={alter:n.c,analyze:function(t){var e=t.type,r=t.table;return[Object(u.toUpper)(e),Object(a.b)(r)].join(" ")},attach:function(t){var e=t.type,r=t.database,n=t.expr,a=t.as,s=t.schema;return[Object(u.toUpper)(e),Object(u.toUpper)(r),Object(o.a)(n),Object(u.toUpper)(a),Object(u.identifierToSql)(s)].filter(u.hasVal).join(" ")},create:s.b,comment:function(t){var e=t.expr,r=t.keyword,n=t.target,o=t.type;return[Object(u.toUpper)(o),Object(u.toUpper)(r),c(n),l(e)].filter(u.hasVal).join(" ")},select:f.a,deallocate:h.c,delete:function(t){var e=t.columns,r=t.from,n=t.table,s=t.where,c=t.orderby,l=t.with,f=t.limit,v=t.returning,d=[Object(b.a)(l),"DELETE"],h=Object(i.i)(e,r);return d.push(h),Array.isArray(n)&&(1===n.length&&!0===n[0].addition||d.push(Object(a.c)(n))),d.push(Object(u.commonOptionConnector)("FROM",a.c,r)),d.push(Object(u.commonOptionConnector)("WHERE",o.a,s)),d.push(Object(o.c)(c,"order by")),d.push(Object(p.a)(f)),d.push(Object(u.returningToSQL)(v)),d.filter(u.hasVal).join(" ")},exec:function(t){var e=t.keyword,r=t.module,n=t.parameters;return[Object(u.toUpper)(e),Object(a.b)(r),(n||[]).map(y).filter(u.hasVal).join(", ")].filter(u.hasVal).join(" ")},execute:h.f,explain:function(t){var e=t.type,r=t.expr;return[Object(u.toUpper)(e),Object(f.a)(r)].join(" ")},for:h.g,update:v.b,if:h.j,insert:d.a,load_data:m.a,drop:h.b,truncate:h.b,replace:d.a,declare:h.d,use:h.o,rename:h.m,call:h.a,desc:h.e,set:h.n,lock:h.k,unlock:h.k,show:j.a,grant:h.h,revoke:h.h,proc:function(t){var e=t.stmt;switch(e.type){case"assign":return Object(w.a)(e);case"return":return function(t){var e=t.type,r=t.expr;return[Object(u.toUpper)(e),Object(o.a)(r)].join(" ")}(e)}},raise:h.l,transaction:function(t){var e=t.expr,r=e.action,n=e.keyword,o=e.modes,a=[Object(u.literalToSQL)(r),Object(u.toUpper)(n)];return o&&a.push(o.map(u.literalToSQL).join(", ")),a.filter(u.hasVal).join(" ")}};function L(t){if(!t)return"";for(var e=O[t.type],r=t,n=r._parentheses,a=r._orderby,s=r._limit,i=[n&&"(",e(t)];t._next;){var c=O[t._next.type],l=Object(u.toUpper)(t.set_op);i.push(l,c(t._next)),t=t._next}return i.push(n&&")",Object(o.c)(a,"order by"),Object(p.a)(s)),i.filter(u.hasVal).join(" ")}function C(t){for(var e=[],r=0,n=t.length;r<n;++r){var o=t[r]&&t[r].ast?t[r].ast:t[r],a=L(o);r===n-1&&"transaction"===o.type&&(a="".concat(a," ;")),e.push(a)}return e.join(" ; ")}},function(t,e,r){"use strict";r.d(e,"a",(function(){return s})),r.d(e,"b",(function(){return i})),r.d(e,"c",(function(){return c})),r.d(e,"d",(function(){return l})),r.d(e,"e",(function(){return p})),r.d(e,"f",(function(){return b})),r.d(e,"g",(function(){return v})),r.d(e,"h",(function(){return f})),r.d(e,"i",(function(){return h})),r.d(e,"j",(function(){return d}));var n=r(2),o=r(1),a=r(0),u=r(15);function s(t){var e=t.args,r=t.type,n=t.over,s=e.expr,i=e.having,c="".concat(Object(a.toUpper)(r),"(").concat(Object(o.a)(s));return i&&(c="".concat(c," HAVING ").concat(Object(a.toUpper)(i.prefix)," ").concat(Object(o.a)(i.expr))),[c="".concat(c,")"),Object(u.a)(n)].filter(a.hasVal).join(" ")}function i(t){if(!t||!t.array)return"";var e=t.array.keyword;if(e)return Object(a.toUpper)(e);for(var r=t.array,n=r.dimension,o=r.length,u=[],s=0;s<n;s++)u.push("["),o&&o[s]&&u.push(Object(a.literalToSQL)(o[s])),u.push("]");return u.join("")}function c(t){for(var e=t.target,r=t.expr,u=t.keyword,s=t.symbol,c=t.as,l=t.offset,f=t.parentheses,p=Object(n.d)({expr:r,offset:l}),b=[],v=0,d=e.length;v<d;++v){var h=e[v],y=h.angle_brackets,m=h.length,w=h.dataType,j=h.parentheses,O=h.quoted,L=h.scale,C=h.suffix,g=h.expr,E=g?Object(o.a)(g):"";null!=m&&(E=L?"".concat(m,", ").concat(L):m),j&&(E="(".concat(E,")")),y&&(E="<".concat(E,">")),C&&C.length&&(E+=" ".concat(C.map(a.literalToSQL).join(" ")));var A="::",T="",S=[];"as"===s&&(0===v&&(p="".concat(Object(a.toUpper)(u),"(").concat(p)),T=")",A=" ".concat(s.toUpperCase()," ")),0===v&&S.push(p);var U=i(h);S.push(A,O,w,O,U,E,T),b.push(S.filter(a.hasVal).join(""))}c&&b.push(" AS ".concat(Object(a.identifierToSql)(c)));var _=b.filter(a.hasVal).join("");return f?"(".concat(_,")"):_}function l(t){var e=t.args,r=t.type,n=e.field,u=e.cast_type,s=e.source,i=["".concat(Object(a.toUpper)(r),"(").concat(Object(a.toUpper)(n)),"FROM",Object(a.toUpper)(u),Object(o.a)(s)];return"".concat(i.filter(a.hasVal).join(" "),")")}function f(t){var e=t.expr,r=e.key,n=e.value,u=e.on,s=[Object(o.a)(r),"VALUE",Object(o.a)(n)];return u&&s.push("ON","NULL",Object(o.a)(u)),s.filter(a.hasVal).join(" ")}function p(t){var e=t.args,r=t.type,n=["input","path","outer","recursive","mode"].map((function(t){return function(t){if(!t)return"";var e=t.type,r=t.symbol,n=t.value;return[Object(a.toUpper)(e),r,Object(o.a)(n)].filter(a.hasVal).join(" ")}(e[t])})).filter(a.hasVal).join(", ");return"".concat(Object(a.toUpper)(r),"(").concat(n,")")}function b(t){var e=t.value,r=e.name,n=e.symbol,u=e.expr;return[r,n,Object(o.a)(u)].filter(a.hasVal).join(" ")}function v(t){var e=t.args,r=t.array_index,s=t.name,i=t.args_parentheses,c=t.parentheses,l=t.within_group,f=t.over,p=t.suffix,b=Object(u.a)(f),v=function(t){if(!t)return"";var e=t.type,r=t.keyword,n=t.orderby;return[Object(a.toUpper)(e),Object(a.toUpper)(r),"(".concat(Object(o.c)(n,"order by"),")")].filter(a.hasVal).join(" ")}(l),d=Object(o.a)(p),h=[Object(a.literalToSQL)(s.schema),s.name.map(a.literalToSQL).join(".")].filter(a.hasVal).join(".");if(!e)return[h,v,b].filter(a.hasVal).join(" ");var y=t.separator||", ";"TRIM"===Object(a.toUpper)(h)&&(y=" ");var m=[h];m.push(!1===i?" ":"(");var w=Object(o.a)(e);if(Array.isArray(y)){for(var j=w[0],O=1,L=w.length;O<L;++O)j=[j,w[O]].join(" ".concat(Object(o.a)(y[O-1])," "));m.push(j)}else m.push(w.join(y));return!1!==i&&m.push(")"),m.push(Object(n.a)(r)),m=[m.join(""),d].filter(a.hasVal).join(" "),[c?"(".concat(m,")"):m,v,b].filter(a.hasVal).join(" ")}function d(t){var e=t.as,r=t.name,n=t.args,u=[Object(a.literalToSQL)(r.schema),r.name.map(a.literalToSQL).join(".")].filter(a.hasVal).join(".");return["".concat(u,"(").concat(Object(o.a)(n).join(", "),")"),"AS",v(e)].join(" ")}function h(t){var e=t.args,r=t.expr,n=e.value,a=e.parentheses,u=n.map(o.a).join(", ");return[a?"(".concat(u,")"):u,"->",Object(o.a)(r)].join(" ")}},function(t,e,r){"use strict";r.d(e,"a",(function(){return i}));var n=r(0),o=r(1);function a(t){return function(t){if(Array.isArray(t))return u(t)}(t)||function(t){if("undefined"!=typeof Symbol&&null!=t[Symbol.iterator]||null!=t["@@iterator"])return Array.from(t)}(t)||function(t,e){if(t){if("string"==typeof t)return u(t,e);var r={}.toString.call(t).slice(8,-1);return"Object"===r&&t.constructor&&(r=t.constructor.name),"Map"===r||"Set"===r?Array.from(t):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?u(t,e):void 0}}(t)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function u(t,e){(null==e||e>t.length)&&(e=t.length);for(var r=0,n=Array(e);r<e;r++)n[r]=t[r];return n}function s(t){return t?[t.prefix.map(n.literalToSQL).join(" "),Object(o.a)(t.value),t.suffix.map(n.literalToSQL).join(" ")]:[]}function i(t){return t?t.fetch||t.offset?(r=(e=t).fetch,u=e.offset,[].concat(a(s(u)),a(s(r))).filter(n.hasVal).join(" ")):function(t){var e=t.seperator,r=t.value;return 1===r.length&&"offset"===e?Object(n.connector)("OFFSET",Object(o.a)(r[0])):Object(n.connector)("LIMIT",r.map(o.a).join("".concat("offset"===e?" ":"").concat(Object(n.toUpper)(e)," ")))}(t):"";var e,r,u}},function(t,e,r){"use strict";r.d(e,"b",(function(){return p})),r.d(e,"a",(function(){return f}));var n=r(3),o=r(1),a=r(2),u=r(7),s=r(0),i=r(16);function c(t,e){var r="undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(!r){if(Array.isArray(t)||(r=function(t,e){if(t){if("string"==typeof t)return l(t,e);var r={}.toString.call(t).slice(8,-1);return"Object"===r&&t.constructor&&(r=t.constructor.name),"Map"===r||"Set"===r?Array.from(t):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?l(t,e):void 0}}(t))||e&&t&&"number"==typeof t.length){r&&(t=r);var n=0,o=function(){};return{s:o,n:function(){return n>=t.length?{done:!0}:{done:!1,value:t[n++]}},e:function(t){throw t},f:o}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var a,u=!0,s=!1;return{s:function(){r=r.call(t)},n:function(){var t=r.next();return u=t.done,t},e:function(t){s=!0,a=t},f:function(){try{u||null==r.return||r.return()}finally{if(s)throw a}}}}function l(t,e){(null==e||e>t.length)&&(e=t.length);for(var r=0,n=Array(e);r<e;r++)n[r]=t[r];return n}function f(t){if(!t||0===t.length)return"";var e,r=[],n=c(t);try{for(n.s();!(e=n.n()).done;){var u=e.value,i={},l=u.value;for(var f in u)"value"!==f&&"keyword"!==f&&(i[f]=u[f]);var p=[Object(a.f)(i)],b="";l&&(b=Object(o.a)(l),p.push("=",b)),r.push(p.filter(s.hasVal).join(" "))}}catch(t){n.e(t)}finally{n.f()}return r.join(", ")}function p(t){var e=t.from,r=t.table,a=t.set,c=t.where,l=t.orderby,p=t.with,b=t.limit,v=t.returning;return[Object(i.a)(p),"UPDATE",Object(n.c)(r),Object(s.commonOptionConnector)("SET",f,a),Object(s.commonOptionConnector)("FROM",n.c,e),Object(s.commonOptionConnector)("WHERE",o.a,c),Object(o.c)(l,"order by"),Object(u.a)(b),Object(s.returningToSQL)(v)].filter(s.hasVal).join(" ")}},function(t,e,r){"use strict";r.d(e,"a",(function(){return p})),r.d(e,"c",(function(){return b})),r.d(e,"b",(function(){return f}));var n=r(2),o=r(14),a=r(11),u=r(3),s=r(1),i=r(13),c=r(0);function l(t,e){switch(t){case"add":var r=e.map((function(t){var e=t.name,r=t.value;return["PARTITION",Object(c.literalToSQL)(e),"VALUES",Object(c.toUpper)(r.type),"(".concat(Object(c.literalToSQL)(r.expr),")")].join(" ")})).join(", ");return"(".concat(r,")");default:return Object(n.i)(e)}}function f(t){if(!t)return"";var e=t.action,r=t.create_definitions,u=t.if_not_exists,s=t.keyword,i=t.if_exists,f=t.old_column,p=t.prefix,b=t.resource,v=t.symbol,d=t.suffix,h="",y=[];switch(b){case"column":y=[Object(n.c)(t)];break;case"index":y=Object(a.c)(t),h=t[b];break;case"table":case"schema":h=Object(c.identifierToSql)(t[b]);break;case"aggregate":case"function":case"domain":case"type":h=Object(c.identifierToSql)(t[b]);break;case"algorithm":case"lock":case"table-option":h=[v,Object(c.toUpper)(t[b])].filter(c.hasVal).join(" ");break;case"constraint":h=Object(c.identifierToSql)(t[b]),y=[Object(o.a)(r)];break;case"partition":y=[l(e,t.partitions)];break;case"key":h=Object(c.identifierToSql)(t[b]);break;default:h=[v,t[b]].filter((function(t){return null!==t})).join(" ")}var m=[Object(c.toUpper)(e),Object(c.toUpper)(s),Object(c.toUpper)(u),Object(c.toUpper)(i),f&&Object(n.f)(f),Object(c.toUpper)(p),h&&h.trim(),y.filter(c.hasVal).join(" ")];return d&&m.push(Object(c.toUpper)(d.keyword),d.expr&&Object(n.f)(d.expr)),m.filter(c.hasVal).join(" ")}function p(t){var e=t.default&&[Object(c.toUpper)(t.default.keyword),Object(s.a)(t.default.value)].join(" ");return[Object(c.toUpper)(t.mode),t.name,Object(c.dataTypeToSQL)(t.type),e].filter(c.hasVal).join(" ")}function b(t){var e=t.keyword;switch(void 0===e?"table":e){case"aggregate":return function(t){var e=t.args,r=t.expr,n=t.keyword,o=t.name,a=t.type,u=e.expr,s=e.orderby;return[Object(c.toUpper)(a),Object(c.toUpper)(n),[[Object(c.identifierToSql)(o.schema),Object(c.identifierToSql)(o.name)].filter(c.hasVal).join("."),"(".concat(u.map(p).join(", ")).concat(s?[" ORDER","BY",s.map(p).join(", ")].join(" "):"",")")].filter(c.hasVal).join(""),f(r)].filter(c.hasVal).join(" ")}(t);case"table":return function(t){var e=t.type,r=t.table,n=t.if_exists,o=t.prefix,a=t.expr,i=void 0===a?[]:a,l=Object(c.toUpper)(e),f=Object(u.c)(r),p=i.map(s.a);return[l,"TABLE",Object(c.toUpper)(n),Object(c.literalToSQL)(o),f,p.join(", ")].filter(c.hasVal).join(" ")}(t);case"schema":return function(t){var e=t.expr,r=t.keyword,n=t.schema,o=t.type;return[Object(c.toUpper)(o),Object(c.toUpper)(r),Object(c.identifierToSql)(n),f(e)].filter(c.hasVal).join(" ")}(t);case"sequence":return function(t){var e=t.type,r=t.keyword,n=t.sequence,a=t.if_exists,s=t.expr,i=void 0===s?[]:s,l=Object(c.toUpper)(e),f=Object(u.c)(n),p=i.map(o.a);return[l,Object(c.toUpper)(r),Object(c.toUpper)(a),f,p.join(", ")].filter(c.hasVal).join(" ")}(t);case"domain":case"type":return function(t){var e=t.expr,r=t.keyword,n=t.name,o=t.type;return[Object(c.toUpper)(o),Object(c.toUpper)(r),[Object(c.identifierToSql)(n.schema),Object(c.identifierToSql)(n.name)].filter(c.hasVal).join("."),f(e)].filter(c.hasVal).join(" ")}(t);case"function":return function(t){var e=t.args,r=t.expr,n=t.keyword,o=t.name,a=t.type;return[Object(c.toUpper)(a),Object(c.toUpper)(n),[[Object(c.identifierToSql)(o.schema),Object(c.identifierToSql)(o.name)].filter(c.hasVal).join("."),e&&"(".concat(e.expr?e.expr.map(p).join(", "):"",")")].filter(c.hasVal).join(""),f(r)].filter(c.hasVal).join(" ")}(t);case"view":return function(t){var e=t.type,r=t.columns,o=t.attributes,a=t.select,s=t.view,l=t.with,f=[Object(c.toUpper)(e),"VIEW",Object(u.b)(s)];return r&&f.push("(".concat(r.map(n.f).join(", "),")")),o&&f.push("WITH ".concat(o.map(c.toUpper).join(", "))),f.push("AS",Object(i.a)(a)),l&&f.push(Object(c.toUpper)(l)),f.filter(c.hasVal).join(" ")}(t)}}},function(t,e,r){"use strict";r.d(e,"a",(function(){return v})),r.d(e,"b",(function(){return l})),r.d(e,"c",(function(){return c}));var n=r(3),o=r(1),a=r(2),u=r(0),s=r(5),i=r(8);function c(t){var e=t.type;return"select"===e?Object(s.b)(t):("values"===e?t.values:t).map((function(t){var e=Object(o.a)(t);return[Object(u.toUpper)(t.prefix),"(".concat(e,")")].filter(u.hasVal).join("")})).join(", ")}function l(t){if(!t)return"";var e=["PARTITION","("];if(Array.isArray(t))e.push(t.map((function(t){return Object(u.identifierToSql)(t)})).join(", "));else{var r=t.value;e.push(r.map(o.a).join(", "))}return e.push(")"),e.filter(u.hasVal).join("")}function f(t){if(!t)return"";switch(t.type){case"column":return"(".concat(t.expr.map(a.f).join(", "),")")}}function p(t){var e=t.expr,r=t.keyword,n=e.type,a=[Object(u.toUpper)(r)];switch(n){case"origin":a.push(Object(u.literalToSQL)(e));break;case"update":a.push("UPDATE",Object(u.commonOptionConnector)("SET",i.a,e.set),Object(u.commonOptionConnector)("WHERE",o.a,e.where))}return a.filter(u.hasVal).join(" ")}function b(t){if(!t)return"";var e=t.action;return[f(t.target),p(e)].filter(u.hasVal).join(" ")}function v(t){var e=t.table,r=t.type,a=t.or,s=void 0===a?[]:a,f=t.prefix,p=void 0===f?"into":f,v=t.columns,d=t.conflict,h=t.values,y=t.where,m=t.on_duplicate_update,w=t.partition,j=t.returning,O=t.set,L=m||{},C=L.keyword,g=L.set,E=[Object(u.toUpper)(r),s.map(u.literalToSQL).join(" "),Object(u.toUpper)(p),Object(n.c)(e),l(w)];return Array.isArray(v)&&E.push("(".concat(v.map(u.literalToSQL).join(", "),")")),E.push(Object(u.commonOptionConnector)(h&&"values"===h.type?"VALUES":"",c,h)),E.push(Object(u.commonOptionConnector)("ON CONFLICT",b,d)),E.push(Object(u.commonOptionConnector)("SET",i.a,O)),E.push(Object(u.commonOptionConnector)("WHERE",o.a,y)),E.push(Object(u.commonOptionConnector)(C,i.a,g)),E.push(Object(u.returningToSQL)(j)),E.filter(u.hasVal).join(" ")}},function(t,e,r){"use strict";r.d(e,"a",(function(){return f})),r.d(e,"d",(function(){return s})),r.d(e,"b",(function(){return c})),r.d(e,"c",(function(){return l}));var n=r(0),o=r(1);function a(t){return function(t){if(Array.isArray(t))return u(t)}(t)||function(t){if("undefined"!=typeof Symbol&&null!=t[Symbol.iterator]||null!=t["@@iterator"])return Array.from(t)}(t)||function(t,e){if(t){if("string"==typeof t)return u(t,e);var r={}.toString.call(t).slice(8,-1);return"Object"===r&&t.constructor&&(r=t.constructor.name),"Map"===r||"Set"===r?Array.from(t):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?u(t,e):void 0}}(t)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function u(t,e){(null==e||e>t.length)&&(e=t.length);for(var r=0,n=Array(e);r<e;r++)n[r]=t[r];return n}function s(t){if(!t)return[];var e=t.keyword,r=t.type;return[e.toUpperCase(),Object(n.toUpper)(r)]}function i(t){if(t){var e=t.type,r=t.expr,o=t.symbol,u=e.toUpperCase(),i=[];switch(i.push(u),u){case"KEY_BLOCK_SIZE":o&&i.push(o),i.push(Object(n.literalToSQL)(r));break;case"BTREE":case"HASH":i.length=0,i.push.apply(i,a(s(t)));break;case"WITH PARSER":i.push(r);break;case"VISIBLE":case"INVISIBLE":break;case"COMMENT":i.shift(),i.push(Object(n.commentToSQL)(t));break;case"DATA_COMPRESSION":i.push(o,Object(n.toUpper)(r.value),Object(n.onPartitionsToSQL)(r.on));break;default:i.push(o,Object(n.literalToSQL)(r))}return i.filter(n.hasV