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

Releases: codeschool/sqlite-parser

v0.9.1

14 Jul 04:15
Compare
Choose a tag to compare

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.

    // 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);
    });
    // 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

  • removed private flag in package.json ahead of first published release

  • pulled out last remnants of promise from core sqlite-parser lib

Notes

  • Even though the Tracer is now pretty good at pinpointing where a SyntaxError occurred, it is still removing CREATE TABLE node when there is a failure in the statement, even though that information should be part of the error message.

v0.8.0

14 Jul 04:23
Compare
Choose a tag to compare

Added

  • additional rule descriptions in grammar.pegjs
  • added several array methods (e.g.: findLast(), takeRight(), pluck()) so that I could remove lodash as a dependency of the "smart error" Tracer class

Changed

  • updated grammar to remove all dependence on modifier clause as it was being used as a catch-all clause for stray parts of statements
  • created defer clause
  • normalized format for common clauses and nodes across different statement types
  • removed range variant that was part of BETWEEN expressions
  • renamed several clauses to match the SQL keywords and/or SQLite manual descriptions used to define them
    • for WITHOUT ROWID in CREATE TABLE: modifier -> optimization
    • for IF NOT EXISTS in all places: modifier: condition
  • cleaned up css in the interactive demo
  • removed lodash dependency in core Tracer. lodash is now only a devDependency again!

Fixed

  • fixed error reporting when there is more than one statement in the input SQL.

    • still need to make sure previous tree is not used if a subsequent statement has an error at the highest level
    SELECT *
    FROM cats;
    SELECT * d
  • fixed rules for double-quoted, backticked, and bracketed identifiers to allow for escapes, leading or trailing spaces, and the full character set that is legal for quoted identifiers, where allowed.

  • fixed datatype names that did not display correctly in generated AST. fixed string literal definition to allow all possible input

  • fixed value format for direction key in PRIMARY KEY table conatrainsts

  • do not show parenthesis in error message for syntax error when there is nothing to put inside them.

  • fixes for css in demo. for example, demo layout off by 1px when at smallest resolution, did a lot of cleanup on demo styles, responsive layout, error notification. also, changed error message format for smart errors.

Notes

  • to support the "smart errors" changes were made to the pegjs library code in lib/compiler/passes/generate-javascript.js. this was done to allow Tracer to get the description names for the rules that are referenced in the error messages. will need to fork pegjs to get the changes to pegjs core into version control so they are not accidentally overwritten.
  • considering removing the promise dependency from the core sqlite-parser library before v1.0.0, as well, so that the parser can be dependency free as a standalone library. people could choose to "promisify" the parser or just use it synchronously instead of being forced to bundle the promise dependency when bundling this package for use in the browser. It actually looks like all the evergreen browsers except IE currently support a native Promise implementation, so having a non-native Promise implementation as a dependency will probably be obsolete pretty soon.

v0.6.0

14 Jul 04:24
Compare
Choose a tag to compare

Added

  • sqlite-parser demo

    • demo/ folder containing interactive demo of parser. demo JavaScript is all in a self-contained, browserified package
    • browserify task added to Gruntfile.js for creating sqlite-parser-demo.js in demo/ as grunt demo and a watcher/livereload version as grunt interactive
    • CodeMirror dependency into devDependencies
    • updated TODO.md and .npmignore for new Interactive demo
  • sqlite-parser distributable

    • browserify task added to Gruntfile.js for creating sqlite-parser-dist.js in dist/ as grunt dist
    • attaches a single function to window as sqliteParser
  • some missing names for grammar rules

  • smarter error messages using rule descriptions and tracer functionality in newest pegjs

  • turned tracer/smart error code into a Tracer class located at tracer.js in src/

    var t = Tracer();
    return new Promise(function(resolve, reject) {
      resolve(parser.parse(source, {
        'tracer': t
      }));
    })
    .catch(function (err) {
      t.smartError(err);
    });

Changed

  • renamed parse.jsr and util.js files in src/ and lib/ folders
  • pointing to latest pegjs master to get latest SyntaxError format
  • parseError1.sql spec updated for new smarter error syntax
  • cleaned up smart error code to follow the most relevant error path of the pegjs trace output

Fixed

  • accidentally repeating first description in the error thrown from the smartError() method of Tracer

    There is a syntax error near FROM Clause [FROM Clause, Table Identifier]

Notes

  • need to remove the lodash dependency from Tracer before v1.0.0

v0.3.1

14 Jul 04:27
Compare
Choose a tag to compare

Added

  • rules line and block comments

  • specs for comment types

    -- Line comment
    /*
    * Block comment /* nested comment */
    */
  • rules for CREATE INDEX

  • specs for CREATE INDEX statement

  • CREATE TRIGGER syntax and AST

  • specs for CREATE TRIGGER statement

  • specs for some expression grouping issues that were experienced when using binary and unary expressions along with AND, OR

    CREATE INDEX `bees`.`hive_state`
    ON `hive` (`happiness` ASC, `anger` DESC)
    WHERE
      `happiness` ISNULL AND `anger` > 0
  • CREATE VIEW syntax and AST

  • specs for CREATE VIEW statement

  • CREATE VIRTUAL TABLE syntax and AST

  • specs for CREATE VIRTUAL TABLE statement

  • allow subquery in parenthesis within FROM clause

  • New specs: Basic Drop Table, Basic Drop Trigger, Basic Function, Basic Subquery, Basic Union, Create Check 1, Create Check 2, Create Foreign Key 1, Create Foreign Key 2, Create Primary Key 1, Create Table Alt Syntax, Expression Like, Expression Table 1, Expression Unary 1, Function Mixed Args, Insert Into Default, Join Types 1, Join Types 2, Select Parts 1, Select Qualified Table 1, Transaction Rollback

  • LICENSE file added

  • .npmignore file added

Changed

  • updated rules and specs to remove use of modifier property in AST

  • allow multiple expressions for GROUP BY clause

    SELECT color, type, name
    FROM hats
    GROUP BY type, color
  • changed AST for create table, constraints, joins, select parts, transactions, unions, triggers to pass new specs

  • INSERT statement VALUES clause AST normalized for value lists and DEFAULT VALUES

    {
      "type": "values",
      "variant": "list",
      "values": []
    },
    {
      "type": "values",
      "variant": "default",
      "values": null
    }
  • normalized AST across all column constraints and table constraints. all table constraints are {"type": "definition", "variant": "constraint"} and contain a definition array that contains the constraint. the constraint in definitions has the same format as the column constraint definition.

  • updated package dependencies

  • index.js file moved to file root, duplicate copies in lib/ and src/ removed

  • going to try and keep (most significant) version numbers synchronized between sqlite-parser and sqlite-tree to avoid confusion going forward

Fixed

  • some grouping errors for unary operators, unary null and binary concatenation

  • The CREATE VIRTUAL TABLE statement previously only worked with expression arguments. Fixed by checking for a column name followed by a type definition or column constraint before assuming the type is an expression list, if these things are found, then treat the arguments as a set of source definitions as in a creation statement for a table.

    CREATE VIRTUAL TABLE happy_table
    USING happy_module(...);
    
      id int -- treat as definitions for CREATE TABLE
      x != 2 -- treat as an expression list
  • allow for nested parenthesis

  • allow multiple binary expressions and concatenation operators within parenthesis

    SELECT *
    FROM hats
    WHERE
      hat OR (shirt AND (shoes OR wig) AND pants)

Notes

  • CREATE VIRTUAL TABLE currently only works with expression arguments and does not support passing column definitions and/or table constraint definitions as is allowed in the SQLite spec for virtual table module arguments.

    CREATE VIRTUAL TABLE vtrl_ads
    USING tbl_creator(
      id int PRIMARY KEY,
      name varchar(50),
      category varchar(15),
      cost int);