Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for LIKE operator in Condition Parser #10

Closed
joshuafcole opened this issue Jul 9, 2014 · 5 comments
Closed

Add support for LIKE operator in Condition Parser #10

joshuafcole opened this issue Jul 9, 2014 · 5 comments

Comments

@joshuafcole
Copy link
Contributor

Really neat project, I keep finding myself implementing pieces and parts of SQL parsers for various projects and finally bit the bullet to look for an existing solution. Overall your project has been working very well! I did just run into an issue while writing test cases for some of my work though -- the LIKE operator is not currently supported. I may take a look at fixing that and putting in a PR, since it's pretty important.

https://github.com/dsferruzza/simpleSqlParser/blob/master/simpleSqlParser.js#L377

Cheers,
Josh

@joshuafcole
Copy link
Contributor Author

Ended up being even simpler, just had to add LIKE to readWord! https://github.com/dsferruzza/simpleSqlParser/blob/master/simpleSqlParser.js#L416

I'll put a PR in and use my branch as the dependency in the meantime.

@dsferruzza
Copy link
Owner

Hi!
I'm happy that my project fits your needs.

I'm currently working on a v2, because v1 is really hard to maintain.
v2 will use parser combinators, as discussed in #6.
You can have a look/try here: https://github.com/dsferruzza/simpleSqlParser/tree/v2

I might work on it tonight, so maybe I'll implement the LIKE.
If I don't, you can do a PR on the v2 branch, but not on master, please.

Could you provide me one or several examples of SQL queries using LIKE you would like the parser to be able to parse?

@joshuafcole
Copy link
Contributor Author

It looks as though v2 already has support for LIKE (with a cursory inspection) but that isn't the package currently available on npm. Here are a few example queries to illustrate the issue:

SELECT nid FROM node WHERE title LIKE "%testing%"

LIKE is not recognized as an operator, so you get some weird results.

Is v2 stable enough to be used in a corporate environment? If so I can freeze to a commit of V2 instead of continuing to use v1. It definitely looks cleaner than v1, but it's also even larger. Have you considered splitting the project up into multiple files and using a build process such as grunt or gulp to concatenate into a release file for the web? At any rate, I've put in a PR against master that fixes the bug. #11

Please let me know how you'd recommend I proceed.

Cheers, Josh.

@joshuafcole
Copy link
Contributor Author

This bug also affects IN, I'll add it in.

joshuafcole pushed a commit to joshuafcole/simpleSqlParser that referenced this issue Jul 9, 2014
joshuafcole pushed a commit to joshuafcole/simpleSqlParser that referenced this issue Jul 9, 2014
@dsferruzza
Copy link
Owner

v2 is still in development so it's not available on npm yet.
It still misses things like documentation and conditions parsing.

Otherwise, v2 seems quite stable to me, which is not hard compared to v1...
But it's still young.
So I wouldn't use it in a corporate environment with a blind trust, but it's worth trying (or it'll be soon).
Let me know if you find some queries that doesn't parse correctly.

I don't plan to split into multiple files, but I haven't decided not to.
So feel free to argue!

I plan to update the gulp tasks to generate plain and minified releases, including and not including Parsimmon (which is the only runtime dependency).
Like v1, it will be available on npm and bower.


Also, I added IN support in v2: f242c3f

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants