From 05a1cc96dcc8abec1bfaad21843173e10469d1b8 Mon Sep 17 00:00:00 2001 From: Vadim Kiryukhin Date: Mon, 27 Feb 2012 00:57:17 -0800 Subject: [PATCH] "last deep" bug fixed, basicsql.html page added --- html/basicsql.html | 23 +++++++++++++++++++++++ index.html | 2 +- main.js | 6 +++--- vkbeautify.js | 2 +- 4 files changed, 28 insertions(+), 5 deletions(-) create mode 100644 html/basicsql.html diff --git a/html/basicsql.html b/html/basicsql.html new file mode 100644 index 0000000..8f66dcf --- /dev/null +++ b/html/basicsql.html @@ -0,0 +1,23 @@ + + + + + +
+
Basic
+
+

This is an example of a SQL statement.

+ +

+vkBeautify SQL parser covers only SELECT statement as most javascript developers most time have deal with SELECT. +As SQL syntax itself is very large and complex, some complex statements can be formatted not as perfect as you'd +done it manually. But anyway, it helps you to read and understand complex SQL statement. +

+

Click on "Pretty Print" button to beatify the text.

+

Click on "Minify" button to minify the text. Not sure if anybody needs it, but I keep it for consistency :)
+("Preserve Comments" has no effect as it doesn't make any sense.) +

+

+ +

+
diff --git a/index.html b/index.html index c39699f..be9755f 100644 --- a/index.html +++ b/index.html @@ -70,7 +70,7 @@

vkBeautify

XML
chars

- +
diff --git a/main.js b/main.js index 5373cf0..20d7250 100644 --- a/main.js +++ b/main.js @@ -152,10 +152,10 @@ function loadTemplate(name) break; case 'basicsql': - $('#ta').width(800); + $('#ta').width(600); $('#leftpanel').show(); - document.getElementById('ta').value = "SELECT aaa from bbb where ccc='ddd'"; - //$('#rightpanel').empty().load('html/basic.html'); + document.getElementById('ta').value = "SELECT ca.proj_id AS proj_id, ca.ca_name AS proj_name, ca.ca_date_start AS proj_start, ca.ca_date_end AS proj_end,(SELECT COUNT(*) FROM rotations r WHERE r.proj_id = proj_id AND r.r_status = 'R' GROUP BY r.proj_id) r_count, (SELECT count(*) FROM rotations r WHERE r.proj_id = proj_id AND r.channel_id = 24 ) r_rtb_count, ca.ca_service_type FROM projs ca, clients c, proj_auth caa WHERE ca.client_id = 12345 AND ca.client_id = c.client_id AND ca_type = 'zzz' AND c.agency_id = 0 AND ca.client_id = NVL( caa.client_id, ca.client_id ) AND proj_id = NVL( caa.proj_id, proj_id ) AND caa.contact_id = 7890"; + $('#rightpanel').empty().load('html/basicsql.html'); $('#rightpanel').empty(); $('#mode').html('SQL'); countChars(); diff --git a/vkbeautify.js b/vkbeautify.js index 12139fe..f440cfc 100644 --- a/vkbeautify.js +++ b/vkbeautify.js @@ -284,7 +284,7 @@ vkbeautify.prototype.sql = function(text, brakeOnComma) { else { parenthesisLevel = isSubquery(parenthesisLevel, ar[ix]); str += this.shift[deep]+ar[ix]; - if(!parenthesisLevel && deep) { + if(parenthesisLevel<1 && deep) { deep--; } }