TinySocial - Fixes ReturnClause unexpected behavior
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 1cd73a9..c3a98b6 100644
--- a/asterix-app/src/main/resources/sdk/static/example/demo.html
+++ b/asterix-app/src/main/resources/sdk/static/example/demo.html
@@ -72,8 +72,8 @@
return $user;
</pre></div>
- <div class="how-to-run">
- </div>
+ <div class="how-to-run"><pre>
+ </pre></div>
<div class="result-output" id="result0b">
</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 c73c45e..26ff378 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
@@ -16,6 +16,25 @@
expression0a.run();
});
+ // 0B - Range Scan
+ $("#run0b").click(function() {
+ $('#result0b').html('');
+
+ var expression0b = new FLWOGRExpression({
+ "dataverse" : "TinySocial",
+ "success" : function(res) {
+ alert(JSON.stringify(res));
+ $('#result0b').html(res["results"]);
+ },
+ })
+ .bind( new ForClause("user", null, new AsterixExpression().set(["dataset FacebookUsers"])) )
+ .bind( new WhereClause( new BooleanExpression("AND", new BooleanExpression(">=", "$user.id", 2), new BooleanExpression("<=", "$user.id", 4)) ) )
+ .bind( new ReturnClause("$user") );
+ alert(expression0b.val());
+ expression0b.run();
+
+ });
+
// 8 - Simple Aggregation
$('#run8').click(function () {
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 5188d13..b972660 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
@@ -395,6 +395,26 @@
LetClause.prototype.constructor = LetClause;
+// ReturnClause
+//
+// Grammar:
+// return [AQLExpression]
+function ReturnClause(expression) {
+ AQLClause.call(this);
+
+ this._properties["clause"] = "return ";
+ if (expression instanceof AExpression) {
+ this._properties["clause"] += expression.val();
+ } else {
+ this._properties["clause"] += new AsterixExpression().set([expression]).val();
+ }
+
+ return this;
+}
+
+ReturnClause.prototype = Object.create(AQLClause.prototype);
+ReturnClause.prototype.constructor = ReturnClause;
+
// WhereClause
//
// Grammar:
@@ -443,6 +463,7 @@
// TODO
function BooleanExpression(expression) {
this.value = expression;
+ alert(arguments.length);
}
BooleanExpression.prototype.val = function() {