Skip to content

Commit eea1459

Browse files
committed
Fix #35: Sort tooltip may incorrectly show Descending
Caused because we tested for @ascending = 1, but @ascending = 'true' can also happen - both are valid.
1 parent 8a756b8 commit eea1459

File tree

2 files changed

+47
-0
lines changed

2 files changed

+47
-0
lines changed

src/qp.xslt

+1
Original file line numberDiff line numberDiff line change
@@ -314,6 +314,7 @@
314314
<div>
315315
<xsl:apply-templates select="s:ColumnReference" mode="ObjectName" />
316316
<xsl:choose>
317+
<xsl:when test="@Ascending = 'true'"> Ascending</xsl:when>
317318
<xsl:when test="@Ascending = 1"> Ascending</xsl:when>
318319
<xsl:otherwise> Descending</xsl:otherwise>
319320
</xsl:choose>

test/qp_test.js

+46
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,8 @@ var plan_StmtUseDb = require('raw!../test_plans/StmtUseDb.sqlplan');
1212
var plan_StmtCond = require('raw!../test_plans/StmtCond.sqlplan');
1313
var plan_NestedLoops = require('raw!../test_plans/nested loops.sqlplan');
1414
var plan_MyCommentScoreDistribution = require('raw!../test_plans/stack overflow/my comment score distribution.sqlplan');
15+
var plan_KeysetCursor = require('raw!../test_plans/cursors/keyset Cursor.sqlplan');
16+
var plan_UpvotesForEachTag = require('raw!../test_plans/stack overflow/How many upvotes do I have for each tag.sqlplan');
1517

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

@@ -307,6 +309,50 @@ describe('qp.js', () => {
307309
});
308310

309311
});
312+
313+
describe('Tooltip Order By', () => {
314+
315+
it('Shows Ascending with @Ascending = true', () => {
316+
317+
var container = document.createElement('div');
318+
QP.showPlan(container, plan_KeysetCursor);
319+
320+
var sort = helper.findNodeById(container, '4', '2');
321+
assert.equal('[Northwind].[dbo].[Employee].EmpName Ascending', helper.getToolTipSection(sort, 'Order By'));
322+
323+
});
324+
325+
it('Shows Descending with @Ascending = false', () => {
326+
327+
var container = document.createElement('div');
328+
QP.showPlan(container, plan_NestedLoops);
329+
330+
var sort = helper.findNodeById(container, '1', '1');
331+
assert.equal('[DataExplorer].[dbo].[Queries].FirstRun Descending', helper.getToolTipSection(sort, 'Order By'));
332+
333+
});
334+
335+
it('Shows Ascending with @Ascending = 1', () => {
336+
337+
var container = document.createElement('div');
338+
QP.showPlan(container, plan_UpvotesForEachTag);
339+
340+
var sort = helper.findNodeById(container, '4', '1');
341+
assert.equal('[StackOverflow.Exported].[dbo].[Tags].TagName Ascending', helper.getToolTipSection(sort, 'Order By'));
342+
343+
});
344+
345+
it('Shows Descending with @Ascending = 0', () => {
346+
347+
var container = document.createElement('div');
348+
QP.showPlan(container, plan_UpvotesForEachTag);
349+
350+
var sort = helper.findNodeById(container, '0', '1');
351+
assert.equal('Expr1012 Descending', helper.getToolTipSection(sort, 'Order By'));
352+
353+
});
354+
355+
});
310356

311357
});
312358

0 commit comments

Comments
 (0)