Statement Classification QUERY, DML, DDL, BLOCK, UNPARSED#1301
Statement Classification QUERY, DML, DDL, BLOCK, UNPARSED#1301manticore-projects wants to merge 4 commits intoJSQLParser:masterfrom
Conversation
Introduce a Statement Classification in order to distinguish QUERY, DML, DDL, BLOCK, UNPARSED Introduce streamlined appendTo() method in order to avoid the creation of multiple StringBuilders Improve Test Coverage for all Statements
7a90cfb to
457ca70
Compare
wumpz
left a comment
There was a problem hiding this comment.
I don't get the improvement of your DDLStatement and stuff. This isDDL and getType == DDL and the need for additional classes. Since we are on Java 8 why not simply put a simple interface to the classes like
interface DDL {
default StatementType getStatementType() {
return StatementType.DDL;
}
}This default stuff even isn't needed.
As well this StringBuffer with appentTo. What's the point?
|
|
||
| @Override | ||
| public StatementType getStatementType() { | ||
| return StatementType.DDL; |
There was a problem hiding this comment.
Why this type method? Your have your grouping by the class.
| return false; | ||
| } | ||
|
|
||
| public boolean isDML() { |
There was a problem hiding this comment.
And additional to this type method there is this boolean stuff as well. Why?
There was a problem hiding this comment.
The was pure convenience for the end user:
- the method
getStatementType()is useful forswitch casestatements - the methods
isFoo()are useful forif elsestatements.
Example: Imagine a SQL Editor as part of a Web Application, where certain normal users shall be able to execute queries but only Admin users shall be able to execute DDLs and maybe only privileged would run DMLs. In this scenario these methods would become very handy because otherwise you will end-up with a long list like:
if (foo instanceof Select) {
Select select = (Select) foo;
...
} else if (foo instanceof Update) {
...
} ...
Good Morning. Thank you for your feedback.
I do not see any disadvantages of this pattern? What counter arguments do you see? Why was the String concatenation better and why would we not eliminate all the StringBuilders then instead? And how would you actually like to design it, if starting from scratch with 15+ years more experience in your bag now? |
Enforcing the |
|
Could you provide your thoughts on the statement classification and why you do not use an interface? |
|
I am not quite sure, why you are closing this? Do you want to restart this statement classification in a new PR? |
|
My impressions was, that you do not like it at all because your never responded to it. If something does not catch within 3 weeks it is usually rubbish -- until it becomes relevant 1 year later. I have salvaged the TEST improvements though and merged them into the 4.2 preparations. Maybe we can have a discussion on your preferred direction and then re-open for the 4.3 cycle. |
|
Strange, the last comment 13 days ago was from me. Did skip it? |
Introduce a Statement Classification in order to distinguish QUERY, DML, DDL, BLOCK, UNPARSED
--> Each statement now extends either
QueryStatementorDMLStatementorDDLStatementorBlockStatementand will return aStatementTypeaccordinglyIntroduce streamlined appendTo() method in order to avoid the creation of multiple StringBuilders
--> Each statement implements the method
StringBuilder appendTo(StringBilder builder)and so does not need to implementtoString()any longer (because that is done inStatementImplonly)Improve Test Coverage for all Statements
Very sorry for touching many files, but this is an 'all or nothing' thing.