Skip to content

Commit

Permalink
add beatifying by SET
Browse files Browse the repository at this point in the history
  • Loading branch information
vkiryukhin committed Jul 2, 2012
1 parent 795b289 commit b2fe4da
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions vkbeautify.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 ")
Expand Down Expand Up @@ -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('~::~');
Expand Down Expand Up @@ -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];
Expand Down

0 comments on commit b2fe4da

Please sign in to comment.