Skip to content

Commit

Permalink
"last deep" bug fixed, basicsql.html page added
Browse files Browse the repository at this point in the history
  • Loading branch information
vkiryukhin committed Feb 27, 2012
1 parent 45070e1 commit 05a1cc9
Show file tree
Hide file tree
Showing 4 changed files with 28 additions and 5 deletions.
23 changes: 23 additions & 0 deletions html/basicsql.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
<table >
<tr><td>
<div class="h6">Basic</div>
</td></tr>
<tr>
<td class="functionDoc">
<p>This is an example of a SQL statement.</p>

<p>
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.
</p>
<p>Click on "<b>Pretty Print</b>" button to beatify the text. </p>
<p>Click on "<b>Minify</b>" button to minify the text. Not sure if anybody needs it, but I keep it for consistency :)<br/>
<span style="font-size:80%">("Preserve Comments" has no effect as it doesn't make any sense.) </span>
</p>
<p>

</p>
</td>

</tr></table>
2 changes: 1 addition & 1 deletion index.html
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ <h1>vkBeautify </h1>
<div id="leftpanel">
<div id="mode">XML </div>
<div style="float:left; margin-left:7em;"><input id="count" type="text" size="5" /> chars</div><br clear="all"/>
<textarea id="ta" style="height:300px;" onclick="countChars()"></textarea>
<textarea id="ta" style="height:400px;" onclick="countChars()"></textarea>
<div>
<input type="button" onclick="beatify()" value="Pretty Print"/>
<span style="display:inline-block;border:solid 1px #cccccc;padding:5px;margin-left:2em;margin-right:2em;">
Expand Down
6 changes: 3 additions & 3 deletions main.js
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down
2 changes: 1 addition & 1 deletion vkbeautify.js
Original file line number Diff line number Diff line change
Expand Up @@ -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--;
}
}
Expand Down

0 comments on commit 05a1cc9

Please sign in to comment.