From b2fe4dabedfbb67e3c9863dfd3dd7eca7bc7f987 Mon Sep 17 00:00:00 2001 From: Vadim Kiryukhin Date: Mon, 2 Jul 2012 09:03:09 -0700 Subject: [PATCH] add beatifying by SET --- vkbeautify.js | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/vkbeautify.js b/vkbeautify.js index 424d4f9..f0784e2 100644 --- a/vkbeautify.js +++ b/vkbeautify.js @@ -256,7 +256,7 @@ function split_sql(str, tab) { .replace(/ FROM /ig,"~::~FROM ") .replace(/ GROUP\s{1,}BY/ig,"~::~GROUP BY ") .replace(/ HAVING /ig,"~::~HAVING ") - //.replace(/ IN /ig,"~::~"+tab+"IN ") + //.replace(/ SET /ig," SET~::~") .replace(/ IN /ig," IN ") .replace(/ JOIN /ig,"~::~JOIN ") @@ -293,6 +293,8 @@ function split_sql(str, tab) { .replace(/ NULL /ig," NULL ") .replace(/ LIKE /ig," LIKE ") .replace(/\s{0,}SELECT /ig,"SELECT ") + .replace(/\s{0,}UPDATE /ig,"UPDATE ") + .replace(/ SET /ig," SET ") .replace(/~::~{1,}/g,"~::~") .split('~::~'); @@ -330,7 +332,11 @@ vkbeautify.prototype.sql = function(text,step) { if( /\s{0,}\s{0,}SELECT\s{0,}/.exec(ar[ix])) { ar[ix] = ar[ix].replace(/\,/g,",\n"+tab+tab+"") } - + + if( /\s{0,}\s{0,}SET\s{0,}/.exec(ar[ix])) { + ar[ix] = ar[ix].replace(/\,/g,",\n"+tab+tab+"") + } + if( /\s{0,}\(\s{0,}SELECT\s{0,}/.exec(ar[ix])) { deep++; str += shift[deep]+ar[ix];