Skip to content

Commit

Permalink
"single quote" bug is fixed
Browse files Browse the repository at this point in the history
  • Loading branch information
vkiryukhin committed Feb 26, 2012
1 parent 953ecfe commit dce70ca
Showing 1 changed file with 5 additions and 26 deletions.
31 changes: 5 additions & 26 deletions vkbeautify.js
Original file line number Diff line number Diff line change
Expand Up @@ -208,6 +208,7 @@ function split_sql(str) {
.replace(/ ON /ig,"~#~ON ")
.replace(/ OR /ig,"~#~\tOR ")
.replace(/ ORDER\s{1,}BY/ig,"~#~ORDER BY ")
.replace(/ OVER /ig,"~#~OVER ")

//.replace(/\s{0,}SELECT /ig,"~#~SELECT ")
//.replace(/\(\s{0,}SELECT /ig," (SELECT ")
Expand Down Expand Up @@ -268,6 +269,10 @@ vkbeautify.prototype.sql = function(text) {
parenthesisLevel = isSubquery(0, ar[ix]);
} else
if( /\'/.exec(ar[ix]) ) {
parenthesisLevel = isSubquery(parenthesisLevel, ar[ix]);
if(!parenthesisLevel && deep) {
deep--;
}
str += ar[ix];
}
else {
Expand All @@ -276,33 +281,7 @@ vkbeautify.prototype.sql = function(text) {
if(!parenthesisLevel && deep) {
deep--;
}

}

//if( /\'/.exec(ar[ix]) ) {
// str += ar[ix];
//}
//else {
// str += this.shift[deep]+ar[ix];
//}



/*
if( /SELECT/.exec(ar[ix])) {
str += this.shift[deep++]+ar[ix];
secondTouch = true;
} else
if( /FROM/.exec(ar[ix])) {
str += this.shift[--deep]+ar[ix];
} else
if( /\'/.exec(ar[ix]) ) {
str += ar[ix];
}
else {
str += this.shift[deep]+ar[ix];
}
*/
}

str = str.replace(/^\n{1,}/,'')/*.replace(/\n[ \t]{0,}/g,"\n");*/.replace(/\n{1,}/g,"\n");
Expand Down

0 comments on commit dce70ca

Please sign in to comment.