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

Include the SQL grammar #24

Open
Hywan opened this issue Dec 9, 2014 · 7 comments
Open

Include the SQL grammar #24

Hywan opened this issue Dec 9, 2014 · 7 comments
Assignees

Comments

@Hywan
Copy link
Member

Hywan commented Dec 9, 2014

Please, see K-Phoen/php-sql-parser#1.

Thoughts?


Want to back this issue? Post a bounty on it! We accept bounties via Bountysource.

@Hywan Hywan self-assigned this Dec 9, 2014
@Metalaka
Copy link
Member

Metalaka commented Dec 9, 2014

It could be a really good base to build tests.

But, Do we need a full grammar ?
I seen at least InsertQuery who are missing in this light grammar.

@Hywan
Copy link
Member Author

Hywan commented Dec 9, 2014

DML would be great for testing, exactly. Either to validate queries build with Hoa\Database\Query or to generate queries (I don't know how it could be useful yet). Maybe the whole DML (SQL2) is not that difficult. Thoughts?

@Ocramius
Copy link

Implementing just SQL92 parsing seems feasible: http://savage.net.au/SQL/sql-92.bnf.html

Using it... not so much. The problem is that SQL92 is not really supported cross-vendor :-\

@Hywan
Copy link
Member Author

Hywan commented Jan 13, 2016

Is it possible to first normalize vendor-SQL to standard-SQL and then apply the grammar?

@Ocramius
Copy link

@Hywan don't think so: it's not a 1:1 transformation anyway

@Ocramius
Copy link

Keeping it SQL92 is feasible, then generating vendor-specific from SQL92, but generating SQL92 from vendor-specific is a huge project (basically becomes a transpiler).

@billschaller
Copy link

There are grammars for MySQL, TSQL, PL/SQL, and SQLite available for antlr. Those would be a good starting point for parsing vendor sql into a common semantic representation. It would have to be a subset, because some things, like cursors, are not going to translate. DDL can pretty well be condensed, discarding a lot of vendor fluff. Another thing to consider is in parsing vendor dialects, we can smuggle vendor features in some cases by adding extra information to the 'common' semantic nodes, and then decorating them later when we generate vendor sql. Examples would be CLUSTERED index modifier, or LIMIT.

Take a look at SqlAlchemy's dialect system.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Development

No branches or pull requests

4 participants