Skip to content
This repository has been archived by the owner on Jul 15, 2021. It is now read-only.

Commit

Permalink
sqlite-parser is now completely free of runtime dependencies as promi…
Browse files Browse the repository at this point in the history
…se has been removed as a dependency. you can still use the library as a promise-based module, but you have to include and require promise manually. refs #2
  • Loading branch information
nwronski committed Jul 5, 2015
1 parent 90aaf5a commit 4ca4cf4
Show file tree
Hide file tree
Showing 10 changed files with 523 additions and 72 deletions.
35 changes: 34 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,39 @@
All notable changes to this project will be documented in this file.

## [Unreleased][unreleased]

## [v0.9.0] - 2015-07-05
### Changed
- `sqlite-parser` is now completely **free of runtime dependencies** as `promise` has been removed as a dependency. you can still use the library as a promise-based module, but you have to include and `require('promise')` manually.

``` javascript
// Promise-based usage
var Promise = require('promise'),
sqliteParser = Promise.denodeify(require('sqlite-parser'));
sqliteParser("SELECT * FROM bees")
.then(function (res) {
// Result AST
console.log(res);
}, function (err) {
// Error
console.log(err);
});
```

``` javascript
// Standard usage
var sqliteParser = require('sqlite-parser');
sqliteParser("SELECT * FROM bees", function (err, res) {
if (err) {
// Error
console.log(err);
} else {
// Result AST
console.log(res);
}
});
```

- forked `pegjs` repository as `nwronski/pegjs` to get the changes into `pegjs` core into version control so they are not accidentally overwritten
- getting closer to displaying correct error location when there are multiple statements in the input SQL

Expand Down Expand Up @@ -257,7 +289,8 @@ fixed value format for direction key in PRIMARY KEY table contrainsts cleaned up
### Added
- First working version of sqlite-parser

[unreleased]: https://github.com/codeschool/sqlite-parser/compare/v0.8.0...HEAD
[unreleased]: https://github.com/codeschool/sqlite-parser/compare/v0.9.0...HEAD
[v0.9.0]: https://github.com/codeschool/sqlite-parser/compare/v0.8.0...v0.9.0
[v0.8.0]: https://github.com/codeschool/sqlite-parser/compare/v0.6.0...v0.8.0
[v0.6.0]: https://github.com/codeschool/sqlite-parser/compare/v0.3.1...v0.6.0
[v0.3.1]: https://github.com/codeschool/sqlite-parser/compare/6388118d601a89d011ecd6f5c215bbc9763444db...v0.3.1
Expand Down
28 changes: 15 additions & 13 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,21 +31,23 @@ npm install sqlite-parser

## Usage

The library exposes a function that accepts a single argument: a string
containing SQL to parse. The method returns a `Promise` that resolves to the
AST object generated from the source string.
The library exposes a function that accepts two arguments: a string
containing SQL to parse and a callback function. The function will invoke
the callback function with the AST object generated from the source string.

``` javascript
var sqliteParser = require('sqlite-parser'),
sampleSQL = "SELECT type, quantity FROM apples WHERE amount > 1";

sqliteParser(sampleSQL)
.then(function (tree) {
// AST generated
console.log(tree);
}, function (err) {
// Parse error thrown
console.log(err);
// Standard usage
var sqliteParser = require('sqlite-parser'),
sampleSQL = "SELECT type, quantity FROM apples WHERE amount > 1";

sqliteParser(sampleSQL, function (err, res) {
if (err) {
// Error
console.log(err);
} else {
// Result AST
console.log(res);
}
});
```

Expand Down
15 changes: 8 additions & 7 deletions demo/js/demo.js
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
(function (root) {
var sqliteParser = require('sqlite-parser'),
util = require('sqlite-parser-util'),
CodeMirror = require('codemirror'),
panel = document.getElementById('ast'),
msgArea = document.getElementById('ast-header'),
elemSql = document.getElementById('sql-text'),
elemAst = document.getElementById('ast-text');
var Promise = require('promise'),
sqliteParser = Promise.denodeify(require('sqlite-parser')),
util = require('sqlite-parser-util'),
CodeMirror = require('codemirror'),
panel = document.getElementById('ast'),
msgArea = document.getElementById('ast-header'),
elemSql = document.getElementById('sql-text'),
elemAst = document.getElementById('ast-text');

require('foldcode');
require('foldgutter');
Expand Down
Loading

0 comments on commit 4ca4cf4

Please sign in to comment.