• R/O
  • SSH
  • HTTPS

format-sql: Commit


Commit MetaInfo

Revision78 (tree)
Time2019-01-23 21:13:32
Authorkimur058

Log Message

INTERSECTとMINUSを対応

Change Summary

Incremental Difference

--- trunk/DMLBreaker3.x/DMLBreaker.js (revision 77)
+++ trunk/DMLBreaker3.x/DMLBreaker.js (revision 78)
@@ -21,7 +21,7 @@
2121 var caseCount = 0;
2222 // BETWEEN句の発生フラグ
2323 var betweenFlg = false;
24-// UNION句の発生フラグ
24+// UNION句の発生フラグ(INTERSECTとMINUSも含む)
2525 var unionFlg = false;
2626 // テーブル配列
2727 var tableArray = new Array();
@@ -504,9 +504,10 @@
504504 i = wkSql.length;
505505 unionFlg = true;
506506
507- } else if (wkAdd.match(/ union /i) != null) {
507+ } else if (wkAdd.match(/ union | minus | intersect /i) != null) {
508508
509- formatSql += wkAdd.substring(0, wkAdd.length - 6) + "\n" + tab + wkAdd.slice(-6);
509+ var len = wkAdd.match(/ intersect /i) != null ? -10 : -6;
510+ formatSql += wkAdd.substring(0, wkAdd.length + len) + "\n" + tab + wkAdd.slice(len);
510511 wkAdd = "\n" + tab;
511512
512513 i = wkSql.length;
@@ -997,15 +998,15 @@
997998
998999
9991000 /**
1000- * 予約語を変換
1001+ * キーワードを変換
10011002 */
10021003 function convertKeyword(type, targetStr) {
10031004
1004- // DML予約語(38種類+WHEN、INNERを除く)
1005- var DML_KEYWORD = ["ALL", "AND", "ANY", "AS", "ASC", "BETWEEN", "BY", "CASE", "DELETE", "DESC", "DISTINCT", "ELSE", "END", "EXISTS", "FROM", "GROUP", "HAVING", "IN", "INDEX", "INSERT", "INTO", "IS", "LIKE", "NOT", "NULL", "ON", "OR", "ORDER", "SELECT", "SET", "THEN", "UNION", "UPDATE", "VALUES", "WHERE", "WITH", "WHEN"];
1005+ // DMLキーワード(39種類)
1006+ var DML_KEYWORD = ["ALL", "AND", "ANY", "AS", "ASC", "BETWEEN", "BY", "CASE", "DELETE", "DESC", "DISTINCT", "ELSE", "END", "EXCEPT", "EXISTS", "FROM", "GROUP", "HAVING", "IN", "INDEX", "INSERT", "INTERSECT", "INTO", "IS", "LIKE", "MINUS", "NOT", "NULL", "ON", "OR", "ORDER", "SELECT", "SET", "THEN", "UNION", "UPDATE", "VALUES", "WHERE", "WITH", "WHEN"];
10061007 // Oracleキーワード(217種類)
10071008 var ORACLE_KEYWORD = ["ABS", "ACOS", "ADD_MONTHS", "APPENDCHILDXML", "ATTIMEZONE", "ASCII", "ASCIISTR", "ASIN", "ATAN", "ATAN2", "AVG", "BFILENAME", "BIN_TO_NUM", "BITAND", "CARDINALITY", "CAST", "CEIL", "CHARTOROWID", "CHR", "COALESCE", "COLLECT", "COMPOSE", "CON_DBID_TO_ID", "CON_GUID_TO_ID", "CON_NAME_TO_ID", "CON_UID_TO_ID", "CONCAT", "CONVERT", "CORR", "CORR_K", "CORR_S", "COS", "COSH", "COUNT", "COVAR_POP", "COVAR_SAMP", "CUME_DIST", "CURRENT_DATE", "CURRENT_TIMESTAMP", "CV", "DATAOBJ_TO_PARTITION", "DBTIMEZONE", "DECODE", "DECOMPOSE", "DELETEXML", "DENSE_RANK", "DEPTH", "DEREF", "DUMP", "EMPTY_BLOB", "EMPTY_CLOB", "EXISTSNODE", "EXP", "EXTRACT", "EXTRACTVALUE", "FEATURE_DETAILS", "FEATURE_ID", "FEATURE_SET", "FEATURE_VALUE", "FIRST", "FIRST_VALUE", "FLOOR", "FROM_TZ", "GREATEST", "GROUP_ID", "GROUPING", "GROUPING_ID", "HEXTORAW", "INITCAP", "INSTR", "INSTRB", "IS_DATE", "ITERATION_NUMBER", "LAG", "LAST", "LAST_DAY", "LAST_VALUE", "LEAD", "LEAST", "LENGTH", "LENGTHB", "LISTAGG", "LN", "LNNVL", "LOCALTIMESTAMP", "LOG", "LOWER", "LPAD", "LTRIM", "MAKE_REF", "MAX", "MEDIAN", "MIN", "MOD", "MONTHS_BETWEEN", "NANVL", "NCHR", "NEW_TIME", "NEXT_DAY", "NLS_CHARSET_DECL_LEN", "NLS_CHARSET_ID", "NLS_CHARSET_NAME", "NLS_INITCAP", "NLS_LOWER", "NLS_UPPER", "NLSSORT", "NTH_VALUE", "NTILE", "NULLIF", "NUMTODSINTERVAL", "NUMTOYMINTERVAL", "NVL", "NVL2", "ORA_DST_AFFECTED", "ORA_DST_CONVERT", "ORA_DST_ERROR", "ORA_HASH", "ORA_INVOKING_USER", "ORA_INVOKING_USERID", "PATH", "PERCENT_RANK", "PERCENTILE_CONT", "PERCENTILE_DISC", "POWER", "POWERMULTISET", "POWERMULTISET_BY_CARDINALITY", "PRESENTNNV", "PRESENTV", "PREVIOUS", "RAWTOHEX", "RAWTONHEX", "REF", "REGEXP_COUNT", "REGEXP_INSTR", "REGEXP_LIKE", "REGEXP_REPLACE", "REGEXP_SUBSTR", "REMAINDER", "REPLACE", "ROUND", "ROW_NUMBER", "ROWIDTOCHAR", "ROWIDTONCHAR", "RPAD", "RTRIM", "SCN_TO_TIMESTAMP", "SESSIONTIMEZONE", "SET", "SIGN", "SIN", "SINH", "SOUNDEX", "SQLCODE", "SQLERRM", "SQRT", "STANDARD_HASH", "STRTOKEN", "STDDEV", "STDDEV_POP", "STDDEV_SAMP", "SUBSTR", "SUBSTRB", "SUM", "SYS_CONNECT_BY_PATH", "SYS_CONTEXT", "SYS_DBURIGEN", "SYS_EXTRACT_UTC", "SYS_GUID", "SYS_TYPEID", "SYS_XMLAGG", "SYS_XMLGEN", "SYSDATE", "SYSTIMESTAMP", "TAN", "TANH", "TIMESTAMP_TO_SCN", "TO_BINARY_DOUBLE", "TO_BINARY_FLOAT", "TO_BLOB", "TO_CHAR", "TO_CHAR", "TO_CLOB", "TO_DATE", "TO_DSINTERVAL", "TO_LOB", "TO_MULTI_BYTE", "TO_NCHAR", "TO_NCLOB", "TO_NUMBER", "TO_RAW", "TO_SINGLE_BYTE", "TO_TIMESTAMP", "TO_TIMESTAMP_TZ", "TO_YMINTERVAL", "TRANSLATE", "TREAT", "TRIM", "TRUNC", "TZ_OFFSET", "UID", "UNISTR", "UPDATEXML", "UPPER", "USER", "USERENV", "VALUE", "VAR_POP", "VAR_SAMP", "VARIANCE", "VSIZE", "WIDTH_BUCKET", "PREV_DAY", "IS_DATE", "YEARS_OF_AGE", "ROUNDUP", "STRTOKEN", "CD_MOD10_WEIGHT"];
1008- // JOINキーワード(10種類、予約語ではない)
1009+ // JOINキーワード(10種類)
10091010 var JOIN_KEYWORD = ["CROSS JOIN", "FULL JOIN", "FULL OUTER JOIN", "INNER JOIN", "LEFT JOIN", "LEFT OUTER JOIN", "RIGHT JOIN", "RIGHT OUTER JOIN", "JOIN", "USING"];
10101011
10111012 var key = "";
@@ -1013,7 +1014,7 @@
10131014 var sqlStr = type == 2 ? "<span class=\"highlight\">MATCH</span>" : "MATCH";
10141015 var oracleStr = type == 2 ? "<span class=\"oracle\">MATCH</span>" : "MATCH";
10151016
1016- // DML予約語を太字の色付けに変換
1017+ // DMLキーワードを太字の色付けに変換
10171018 for (var i = 0; i < DML_KEYWORD.length; i++) {
10181019
10191020 key = configKeyword == 2 ? DML_KEYWORD[i].toLowerCase() : DML_KEYWORD[i];
Show on old repository browser