Permalink
Browse files

where clause

  • Loading branch information...
1 parent 19943b9 commit fa93f046fa4927fc6860da49bcbe13e4f3c66eac @steveyen committed Apr 23, 2011
Showing with 30 additions and 2 deletions.
  1. +2 −1 sql.pegjs
  2. +28 −1 views/index.erb
View
@@ -268,7 +268,8 @@ select_core =
} ) )
f: ( j: ( ( FROM join_source )? )
{ return j ? j[1] : [] } )
- w: ( ( WHERE expr )? )
+ w: ( e: ( ( WHERE expr )? )
+ { return e ? e[1] : [] } )
g: ( GROUP BY ( ordering_term comma )+ ( HAVING expr )? )? )
{ c[1].unshift(c[0]);
var res = { results: c[1] };
View
@@ -58,7 +58,7 @@ test("smoke", 2, function() {
}]);
});
-test("from-clause", 2, function() {
+test("smoke-from", 2, function() {
var parser = PEG.buildParser(sql_pegjs);
ok(parser);
var s = parser.parse(
@@ -84,6 +84,33 @@ test("from-clause", 2, function() {
]
}]);
});
+
+test("smoke-where", 2, function() {
+ var parser = PEG.buildParser(sql_pegjs);
+ ok(parser);
+ var s = parser.parse(
+ "SELECT * FROM a WHERE a = a;");
+ deepEqual(s, [
+ {
+ "stmt": "select",
+ "select_cores": [ {
+ "results": [ { "column": "*" } ],
+ "from": [
+ { "table": "a" },
+ { "join_constraint": null,
+ "join_op": "JOIN",
+ "table": "b"
+ },
+ { "join_constraint": null,
+ "join_op": "JOIN",
+ "table": "x",
+ "alias": "b1"
+ }
+ ]
+ }
+ ]
+ }]);
+});
</script>
<div>

0 comments on commit fa93f04

Please sign in to comment.