Skip to content

Commit

Permalink
where clause
Browse files Browse the repository at this point in the history
  • Loading branch information
steveyen committed Apr 23, 2011
1 parent 19943b9 commit fa93f04
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 2 deletions.
3 changes: 2 additions & 1 deletion sql.pegjs
Expand Up @@ -268,7 +268,8 @@ select_core =
} ) ) } ) )
f: ( j: ( ( FROM join_source )? ) f: ( j: ( ( FROM join_source )? )
{ return j ? j[1] : [] } ) { return j ? j[1] : [] } )
w: ( ( WHERE expr )? ) w: ( e: ( ( WHERE expr )? )
{ return e ? e[1] : [] } )
g: ( GROUP BY ( ordering_term comma )+ ( HAVING expr )? )? ) g: ( GROUP BY ( ordering_term comma )+ ( HAVING expr )? )? )
{ c[1].unshift(c[0]); { c[1].unshift(c[0]);
var res = { results: c[1] }; var res = { results: c[1] };
Expand Down
29 changes: 28 additions & 1 deletion views/index.erb
Expand Up @@ -58,7 +58,7 @@ test("smoke", 2, function() {
}]); }]);
}); });


test("from-clause", 2, function() { test("smoke-from", 2, function() {
var parser = PEG.buildParser(sql_pegjs); var parser = PEG.buildParser(sql_pegjs);
ok(parser); ok(parser);
var s = parser.parse( var s = parser.parse(
Expand All @@ -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> </script>


<div> <div>
Expand Down

0 comments on commit fa93f04

Please sign in to comment.