-
-
Notifications
You must be signed in to change notification settings - Fork 1.3k
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
Statement Classification QUERY, DML, DDL, BLOCK, UNPARSED #1301
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
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why this type method? Your have your grouping by the class.
return false; | ||
} | ||
|
||
public boolean isDML() { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
And additional to this type method there is this boolean stuff as well. Why?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The was pure convenience for the end user:
- the method
getStatementType()
is useful forswitch case
statements - the methods
isFoo()
are useful forif else
statements.
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
QueryStatement
orDMLStatement
orDDLStatement
orBlockStatement
and will return aStatementType
accordinglyIntroduce 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 inStatementImpl
only)Improve Test Coverage for all Statements
Very sorry for touching many files, but this is an 'all or nothing' thing.