• R/O
  • SSH
  • HTTPS

format-sql: コミット


コミットメタ情報

リビジョン64 (tree)
日時2018-02-22 12:22:44
作者kimur058

ログメッセージ

or、and、caseの整形不備と、JOINキーワードの色付け不備を修正

変更サマリ

差分

--- trunk/DMLBreaker3.x/DMLBreaker.js (revision 63)
+++ trunk/DMLBreaker3.x/DMLBreaker.js (revision 64)
@@ -193,6 +193,10 @@
193193 // 余分な半角スペースを除去
194194 wkSql = formatTrim(wkSql);
195195
196+ // 未対応パターンを対応パターンに変換
197+ wkSql = wkSql.replace(/ or\(/g, " or (");
198+ wkSql = wkSql.replace(/ and\(/g, " and (");
199+
196200 // SELECT
197201 if (wkSql.match(/^select /i) != null) {
198202
@@ -901,7 +905,7 @@
901905 */
902906 function formatCase(formatSql) {
903907
904- if (wkAdd.match(/ case |^case |\tcase | case$|^case$|\(case |\(case$/i) != null) {
908+ if (wkAdd.match(/ case |^case |\tcase |,case | case$|^case$|\(case |\(case$/i) != null) {
905909
906910 formatSql += wkAdd;
907911 wkAdd = "";
@@ -957,7 +961,7 @@
957961 // Oracleキーワード(217種類)
958962 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"];
959963 // JOINキーワード(10種類、予約語ではない)
960- var JOIN_KEYWORD = ["CROSS JOIN", "FULL JOIN", "FULL OUTER JOIN", "INNER JOIN", "JOIN", "LEFT JOIN", "LEFT OUTER JOIN", "RIGHT JOIN", "RIGHT OUTER JOIN", "USING"];
964+ var JOIN_KEYWORD = ["CROSS JOIN", "FULL JOIN", "FULL OUTER JOIN", "INNER JOIN", "LEFT JOIN", "LEFT OUTER JOIN", "RIGHT JOIN", "RIGHT OUTER JOIN", "JOIN", "USING"];
961965
962966 var key = "";
963967 var newStr = "";
--- trunk/DMLBreaker3.x Simple/DMLBreaker.js (revision 63)
+++ trunk/DMLBreaker3.x Simple/DMLBreaker.js (revision 64)
@@ -193,6 +193,10 @@
193193 // 余分な半角スペースを除去
194194 wkSql = formatTrim(wkSql);
195195
196+ // 未対応パターンを対応パターンに変換
197+ wkSql = wkSql.replace(/ or\(/g, " or (");
198+ wkSql = wkSql.replace(/ and\(/g, " and (");
199+
196200 // SELECT
197201 if (wkSql.match(/^select /i) != null) {
198202
@@ -901,7 +905,7 @@
901905 */
902906 function formatCase(formatSql) {
903907
904- if (wkAdd.match(/ case |^case |\tcase | case$|^case$|\(case |\(case$/i) != null) {
908+ if (wkAdd.match(/ case |^case |\tcase |,case | case$|^case$|\(case |\(case$/i) != null) {
905909
906910 formatSql += wkAdd;
907911 wkAdd = "";
@@ -957,7 +961,7 @@
957961 // Oracleキーワード(217種類)
958962 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"];
959963 // JOINキーワード(10種類、予約語ではない)
960- var JOIN_KEYWORD = ["CROSS JOIN", "FULL JOIN", "FULL OUTER JOIN", "INNER JOIN", "JOIN", "LEFT JOIN", "LEFT OUTER JOIN", "RIGHT JOIN", "RIGHT OUTER JOIN", "USING"];
964+ var JOIN_KEYWORD = ["CROSS JOIN", "FULL JOIN", "FULL OUTER JOIN", "INNER JOIN", "LEFT JOIN", "LEFT OUTER JOIN", "RIGHT JOIN", "RIGHT OUTER JOIN", "JOIN", "USING"];
961965
962966 var key = "";
963967 var newStr = "";
旧リポジトリブラウザで表示