Skip to content

Commit

Permalink
Seems sqld3 is just toy.
Browse files Browse the repository at this point in the history
  • Loading branch information
alsotang committed Jan 15, 2014
1 parent 51ee2db commit c0e383e
Show file tree
Hide file tree
Showing 5 changed files with 12 additions and 4 deletions.
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
build: lib/sql.pegjs
@pegjs lib/sql.pegjs lib/sqlparser.js
@./node_modules/.bin/pegjs lib/sql.pegjs lib/sqlparser.js

test:
@./node_modules/.bin/mocha
Expand Down
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
# sql.pegjs

**[WARN]https://github.com/steveyen/sqld3 seems just a toy, so do not use both projects of us.**

This project is a SQL parser based on PEG([parsing expression grammar](http://en.wikipedia.org/wiki/Parsing_expression_grammar)).

And the `sql.pegjs` file is modified from [https://github.com/steveyen/sqld3](https://github.com/steveyen/sqld3).
Expand Down
2 changes: 0 additions & 2 deletions lib/parser.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
var peg = require('pegjs');
var fs = require('fs');
var parser = require('./sqlparser');

module.exports = parser;
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "sql.pegjs",
"version": "1.0.0",
"version": "0.1.0",
"description": "A sql parser based on peg.js",
"main": "index.js",
"scripts": {
Expand Down
8 changes: 8 additions & 0 deletions test/parser.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -65,9 +65,17 @@ describe('parser.test.js', function () {
]);
});

// it('should parse `ORDER BY`', function () {
// var sql = 'SELECT table1.field1 FROM table1 ORDER BY table1.field1;';
// console.log('%j', parser.parse(sql));
// parser.parse(sql)
// .should.eql([]);
// });

it('should be case-insensitive', function () {
var sql = 'sElEcT * FroM users;';
parser.parse(sql)
.should.eql([{"stmt":"select","select_cores":[{"results":[{"column":"*"}],"from":[{"table":"users"}]}]}]);
});

});

0 comments on commit c0e383e

Please sign in to comment.