Code Monkey home page Code Monkey logo

Comments (5)

nwronski avatar nwronski commented on July 4, 2024

It looks like the grammar isn't happy with the parenthesis on the left side ((value2 * 5)) of the expression. Your example is definitely valid. I will look into a fix for this one.

Looking at it closer, there appears to also be a problem when trying to switch the two sides of the inner expression:

SELECT * FROM temptable where value1 = (value3 * -1 + (value2 * 5))

Currently, the parser is treating this as if it is the expression: value3 * -(1 + (value2 * 5))

from sqlite-parser.

nwronski avatar nwronski commented on July 4, 2024

Based on further investigation, the expression parsing works for simple expressions, but is not obeying order of operations or correctly composing complex expressions. For example:

-- parsed as -(1 * (2+3)) instead of (-1) * (2 + 3)
SELECT * FROM t where -1 * (2 + 3)

-- parsed as 3 + (4 * (5 > 20)) instead of (3 + (4 * 5)) > 20
SELECT * FROM t where 3 + 4 * 5 > 20

I will need to rewrite the expression parsing grammar for the next release to:

  • Obey order of operations: * is higher than +, etc...
  • Compose in the correct order: unary expressions, then binary expressions, then logical and/or (AND, OR), etc...
  • Allow for nesting parenthesis on either side of a binary expression

Expect these changes in release v0.15.0.

from sqlite-parser.

nwronski avatar nwronski commented on July 4, 2024

@anvog I just released a beta version of the parser that contains the fix for the issue you were experiencing 0.15.0-beta.

You can install it via npm using (for now):

npm i sqlite-parser@beta

or, you can also try it out online here.

Let me know if you encounter any more problems, thanks!

from sqlite-parser.

nwronski avatar nwronski commented on July 4, 2024

Whoops, didn't mean to close this one just yet. Will close after 0.15.0 is out of beta.

from sqlite-parser.

nwronski avatar nwronski commented on July 4, 2024

Closing this one, but still need beta flag to install at the moment. (Latest: v1.0.0-beta)

npm i sqlite-parser@beta

from sqlite-parser.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.