Skip to content

Commit

Permalink
Fix #46 - SP nodes shown incorrectly
Browse files Browse the repository at this point in the history
The default recursive template for NodeLabel was causing issues and there was nothing to handle showing the SP name or to identify the node type as SP.
  • Loading branch information
JustinPealing committed Nov 16, 2017
1 parent 3dcc2a9 commit 84feae0
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 1 deletion.
8 changes: 8 additions & 0 deletions src/qp.xslt
Expand Up @@ -7,6 +7,7 @@
<xsl:output method="html" indent="no" omit-xml-declaration="yes" />

<!-- Disable built-in recursive processing templates -->
<xsl:template match="*|/|text()|@*" mode="NodeLabel" />
<xsl:template match="*|/|text()|@*" mode="NodeLabel2" />
<xsl:template match="*|/|text()|@*" mode="ToolTipDescription" />
<xsl:template match="*|/|text()|@*" mode="ToolTipDetails" />
Expand Down Expand Up @@ -351,6 +352,11 @@
<div class="qp-bold">Statement</div>
<div><xsl:value-of select="." /></div>
</xsl:template>

<xsl:template match="s:StmtSimple/s:StoredProc" mode="ToolTipDetails">
<div class="qp-bold">Procedure Name</div>
<div><xsl:value-of select="@ProcName" /></div>
</xsl:template>

<xsl:template match="s:Sort/s:OrderBy[count(s:OrderByColumn/s:ColumnReference) > 0]" mode="ToolTipDetails">
<div class="qp-bold">Order By</div>
Expand Down Expand Up @@ -477,6 +483,8 @@
<xsl:template match="*[@StatementType]" mode="NodeLabel">
<xsl:value-of select="@StatementType" />
</xsl:template>

<xsl:template match="*[s:StoredProc]" mode="NodeLabel">Stored Procedure</xsl:template>

<xsl:template match="*[s:CursorPlan/@CursorActualType = 'Dynamic']" mode="NodeLabel">Dynamic</xsl:template>
<xsl:template match="*[s:CursorPlan/@CursorActualType = 'FastForward']" mode="NodeLabel">Fast Forward</xsl:template>
Expand Down
21 changes: 21 additions & 0 deletions test/qp_test.js
Expand Up @@ -18,6 +18,7 @@ let plan_Cursor2 = require('raw!../test_plans/cursors/cursor2.sqlplan');
let plan_batchMode = require('raw!../test_plans/batch mode.sqlplan');
let plan_batchModeEstimated = require('raw!../test_plans/batch mode estimated.sqlplan');
let plan_issue39 = require('raw!../test_plans/issue_39.sqlplan');
let plan_manyLines = require('raw!../test_plans/many_lines2.sqlplan');

describe('qp.js', () => {

Expand Down Expand Up @@ -216,6 +217,26 @@ describe('qp.js', () => {
assert.equal('PRINT', printNode.children[1].innerText);

});

describe('Stored Procedure Node', () => {

it('Has Stored Procedure as node text', () => {

let container = helper.showPlan(plan_manyLines);
let sp = container.querySelectorAll('.qp-node')[1];
assert.equal('Stored Procedure', sp.children[1].innerText);

})

it('Has Procedure Name in tooltip', () => {

let container = helper.showPlan(plan_manyLines);
let sp = container.querySelectorAll('.qp-node')[1];
assert.equal('TEST', helper.getToolTipSection(sp, 'Procedure Name'));

});

});

describe('Tooltip Ordered Property', () => {

Expand Down
2 changes: 1 addition & 1 deletion test_plans/many_lines2.sqlplan
@@ -1,4 +1,4 @@
<?xml version="1.0" encoding="utf-16"?>
<?xml version="1.0" encoding="utf-8"?>
<ShowPlanXML xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" Version="1.5" Build="13.0.1722.0" xmlns="http://schemas.microsoft.com/sqlserver/2004/07/showplan">
<BatchSequence>
<Batch>
Expand Down

0 comments on commit 84feae0

Please sign in to comment.