Cleans up ReturnClause
diff --git a/asterix-app/src/main/resources/sdk/static/example/demo.html b/asterix-app/src/main/resources/sdk/static/example/demo.html
index 46fb89f..9d98546 100644
--- a/asterix-app/src/main/resources/sdk/static/example/demo.html
+++ b/asterix-app/src/main/resources/sdk/static/example/demo.html
@@ -283,7 +283,7 @@
var expression8 = new FunctionExpression(
"count",
new ForClause("fbu", null, new AQLClause().set("dataset FacebookUsers"))
- .bind( new ReturnClause( new AQLClause().set("$fbu") ))
+ .bind(new ReturnClause("$fbu"))
);
OR
@@ -292,7 +292,7 @@
.fn("count")
.expression(
new ForClause("fbu", null, new AQLClause().set("dataset FacebookUsers"))
- .bind( new ReturnClause( new AQLClause().set("$fbu") ))
+ .bind(new ReturnClause("$fbu"))
);
</code></pre></div>
diff --git a/asterix-app/src/main/resources/sdk/static/example/js/demo.js b/asterix-app/src/main/resources/sdk/static/example/js/demo.js
index 4724d25..c31b970 100644
--- a/asterix-app/src/main/resources/sdk/static/example/js/demo.js
+++ b/asterix-app/src/main/resources/sdk/static/example/js/demo.js
@@ -168,11 +168,10 @@
$('#result8').html('');
- // Version 1
var expression8 = new FunctionExpression(
"count",
new ForClause("fbu", null, new AQLClause().set("dataset FacebookUsers"))
- .bind( new ReturnClause( new AQLClause().set("$fbu") ))
+ .bind( new ReturnClause("$fbu") )
);
var success8 = function(res) {
@@ -265,7 +264,7 @@
"similar-tweets": new FLWOGRExpression()
.bind( new ForClause( "t2", null, new AExpression().set("dataset TweetMessages") ))
.bind( new AQLClause().set("where $t2.referred-topics ~= $t.referred-topics and $t2.tweetid != $t.tweetid") )
- .bind( new ReturnClause(new AQLClause().set("$t2.referred-topics")))
+ .bind( new ReturnClause("$t2.referred-topics"))
}));
var success11 = function(res) {
diff --git a/asterix-app/src/main/resources/sdk/static/js/asterix-sdk-stable.js b/asterix-app/src/main/resources/sdk/static/js/asterix-sdk-stable.js
index 1b4f754..4584bcc 100644
--- a/asterix-app/src/main/resources/sdk/static/js/asterix-sdk-stable.js
+++ b/asterix-app/src/main/resources/sdk/static/js/asterix-sdk-stable.js
@@ -199,10 +199,6 @@
AQLClause.prototype.val = function() {
var value = this._properties["clause"];
-
- if (this._properties.hasOwnProperty("return")) {
- value += " return " + this._properties["return"].val();
- }
return value;
};
@@ -281,9 +277,13 @@
AQLClause.call(this);
this._properties["clause"] = "return ";
+
if (expression instanceof AExpression || expression instanceof AQLClause) {
this._properties["clause"] += expression.val();
- } else if ( Object.getPrototypeOf( expression ) === Object.prototype ) {
+
+ } else if ( typeof expression == "object" && Object.getPrototypeOf( expression ) === Object.prototype ) {
+
+ // TODO Null object check
this._properties["clause"] += "{";
var returnStatements = [];
@@ -299,19 +299,16 @@
this._properties["clause"] += "}";
} else {
- this._properties["clause"] += new AExpression().set(expression).val();
+ this._properties["clause"] += new AQLClause().set(expression).val();
}
return this;
}
+
ReturnClause.prototype = Object.create(AQLClause.prototype);
ReturnClause.prototype.constructor = ReturnClause;
-ReturnClause.prototype.val = function () {
- return this._properties["clause"];
-};
-
// WhereClause
//