Closed jcubic closed 5 years ago
This plugin actually hasn't been released. It turns out getting a working SQL parser in JavaScript is a daunting task. Every parser I found had open issues that made some queries not work. The only parser I found that was solid was AlaSQL's.
The problem with their parser is it doesn't support many of the query actions nanoSQL uses, so I need to figure out how to add new syntax to the parser before I can release the plugin.
Anyone who knows JIISON is welcome to help me, would get it done faster!
I was doing research when I was writing blog post about parser generators, Jison don't have best syntax for creating any parser. The ones I like are Nearley and Peg.js. I would be able to help but not with Jison, sorry.
Will play with the plugin on Codepen, and wait for first release. Great project.
I'm certainly not tied to the AlaSQL parser. I just need SOME way to get SQL => AST in javascript and also have the ability to add new query actions besides SELECT/INSERT etc.
If you know of a project that fits those requirements please let me know.
@ClickSimply could that parser then be used to create the nanoSQL tables
from a raw .sql file? That would make the transition way easier 😍
Yeah, that's the plan. CREAT TABLE and ALTER TABLE queries would work in addition to the SELECT statements and what not.
Just need to get a good SQL parser in place before the plugin can be built.
@ClickSimply I would start with writing unit test for different type of queries that the langauge need to support (it will test the parser -> AST). Then you can start to adding features to AlaSQL parser. I may try to help to add first change to the parser to add some feature, you will have foundation how to add new things. Maybe I will be able to add more. But I don't know if I succeed, the parser source is kind of big and complex but maybe not that hard to modify.
I would love to have finished project that have SQL like syntax with strings.
One more suggestion, prepared statements are very good idea and show only examples that show to use those, if this will be run on server string concatenation is always bad idea, that can lead to SQL injection, you can prevent this from the start, and when there are bugs in escapes fix everyone code when users upgrade the library.
Not a bad idea, might start off just supporting a small subset of SQLite commands/syntax.
Seems like we could reach the 90/10 pretty easily.
Is your feature request related to a problem? Please describe. The name of the package suggest it's SQL but you don't use SQL syntax only JS functions that match to SQL queries.
Describe the solution you'd like It would be nice if you have actual raw SQL queries instead of just bunch of functions. This would be an option that will be side by site with current API.
Describe alternatives you've considered I was thinking, if this abstraction is so great and it works with multiple DBs, maybe it would be useful to create a parser of SQL (using parser generator) and use this with the nano-SQL so you have actual SQL. This could be additional library that is mention in docs, like extension.
Additional context SQL is language: the syntax look like this:
this is proper syntax for something that have SQL in name.
as reference check AlaSQL library that have actual queries.
What you think about this?