-
-
Notifications
You must be signed in to change notification settings - Fork 18
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
Use phpmyadmin/sql-parser #313
Conversation
I really love the idea of exploring sql parser stuff. IMO we should not have sql parser types within our interface. another idea: introduce a ParsingReflector which works on the result of another QueryReflector and can use knowledge about the actual query and to refine the result the wrapped reflector returned. sprinkled sql parser dependencies across the whole codebase should be prevented if possible |
You could do that, but every time you pass around the query it needs to be re-parsed in relevant spots, e.g. if you wanted to use it for getQueryType too At least this basic exploration should push the implementation in the right direction. |
would also be interessting whether the parsing is slow .. I guess the parsing will be faster then any sql query we send to the db, so the overhead might be not relevant |
Perhaps there should be a Statement interface added? It would contain the original query, have a method to get a simulated version etc. |
Imo a prototype should at first explore what information we get/need for sql parsing based inference, e.g.
after we know the answer to this questions we can decide how we should at best integrate the existing api and the sql parser api |
Not entirely sure what you mean by 2 phases, wouldn't you want to use the parser to build a proper query for simulation? I reverted the interface change by the way, it's just parsing in the relevant methods for now. |
the already existing features work pretty good without a query parser. we can get better in edge cases, but as is most things I am fine with. Primarily I would want to use the sql parser to allow type inference in cases, where its not technical possible with the current design (meaning by looking at the result-set types as we do atm). at least thats the idea how I would do it currently - but I am open for other approaches in case we see a working prototype beforehand. the PR here - as is - is fine, but solves a "different problem". its mostly a refactoring of already existing featues. |
That's what I thought would be a good and simple way to bring the parser in, specifically to get rid of the regex based stuff for query manipulation. |
yep thats fine. a "side effect" of having a parser, but not my primary motivation. |
sql-parser does parse out expressions, so it is trivial to get the function (like COUNT), I pushed a basic example on how it could work (disregarding the place where I put it) |
Cool, thats a first step. When thinking about a more involved case like min/max we would need something like Parse the query to a expr like The challenge would be on how to get all this information together |
This is a proof of concept.
One of the 'problems' is if the query does not parse, parser will throw it, instead of sending the supposedly invalid query to the server.