Commit 5a58c6d5 authored by Alexander Schlemmer's avatar Alexander Schlemmer
Browse files

FIX: 19 empty result sets now dont lead to the creation of a table

parent 14e06f94
......@@ -76,7 +76,9 @@
</xsl:if>
<xsl:apply-templates mode="query-results" select="./ParseTree"/>
</div>
<xsl:apply-templates mode="select-table" select="./Selection"/>
<xsl:if test="@results!=0">
<xsl:apply-templates mode="select-table" select="./Selection"/>
</xsl:if>
</xsl:template>
<xsl:template match="Selection" mode="select-table">
<div class="panel panel-default caosdb-select-table">
......
......@@ -55,6 +55,67 @@ QUnit.test("basic properties of select-table feature", function(assert) {
assert.equal(html.firstElementChild.className, "panel panel-default caosdb-select-table", "first child has class caosdb-select-table.");
});
/* Test table of empty result sets of queries */
QUnit.test("empty results in SELECT create no table", function(assert) {
var testresult = '\
<?xml version="1.0" encoding="UTF-8"?>\
<Response count="0">\
<Query string="select test from bla" results="0">\
<ParseTree>(cq select (prop_sel (prop_subsel (selector_txt t e s t ))) from (entity bla) &lt;EOF&gt;)</ParseTree>\
<Role />\
<Entity>bla</Entity>\
<Selection>\
<Selector name="test" />\
</Selection>\
</Query>\
</Response>\
';
var xml = str2xml(testresult);
var html = applyTemplates(xml, this.queryXSL, "query-results");
assert.equal(html.children.length, 1);
// For select queries actually containing results, this would be 2.
});
// This uses results from the demo server.
QUnit.test("one result in SELECT create table", function(assert) {
var testresult = '\
<?xml version="1.0" encoding="UTF-8"?>\
<Response count="12">\
<Query string="SELECT Width, Result, Success FROM MySimulation" results="1">\
<ParseTree>(cq SELECT (prop_sel (prop_subsel (selector_txt W i d t h)) , (prop_subsel (selector_txt R e s u l t)) , (prop_subsel (selector_txt S u c c e s s ))) FROM (entity MySimulation) &lt;EOF&gt;)</ParseTree>\
<Role />\
<Entity>MySimulation</Entity>\
<Selection>\
<Selector name="Width" />\
<Selector name="Result" />\
<Selector name="Success" />\
</Selection>\
</Query>\
<Record id="243">\
<Permissions />\
<Property id="235" name="Width" datatype="INTEGER" importance="FIX" unit="px">\
200\
<Permissions />\
</Property>\
<Property id="237" name="Result" datatype="DOUBLE" importance="FIX">\
1.25\
<Permissions />\
</Property>\
<Property id="238" name="Success" datatype="BOOLEAN" importance="FIX">\
TRUE\
<Permissions />\
</Property>\
</Record>\
</Response>';
var xml = str2xml(testresult);
var html = applyTemplates(xml, this.queryXSL, "query-results");
assert.equal(html.children.length, 2);
});
/* -- -- */
QUnit.test("Query tag is transformed via xslt", function(assert) {
assert.equal(this.queryXSL.getElementsByClassName("caosdb-query-response")[0].tagName, "div", "xsl sheet defines a caosdb-query response div");
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment