-
-
Notifications
You must be signed in to change notification settings - Fork 1.4k
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
Fluent builder api #1004 #1014
Fluent builder api #1004 #1014
Conversation
* create(...) methods * chaining - methods returning "this" * overwrite chaining - methods of abstract parents/interfaces for returning concrete type * add<Name> methods on collection-fields with varargs-parameter * add public T get<Name>(Class<T>) - casting and returning an inner interface-type
…r.git into master.fluent
* add<Name> methods on collection-fields with collection-parameter JSQLParser#1004
…r.git into master.fluent
* add<Name> methods on collection-fields with varargs-parameter * add<Name> methods on collection-fields with collection-parameter JSQLParser#1004
type (swap Class<? extends E> for Class<E>) JSQLParser#1004
returning concrete type JSQLParser#1004
…r.git into master.fluent
not break current api) JSQLParser#1004
not break current api) JSQLParser#1004
https://github.com/gitmotte/JSqlParser.git into master.fluent
* add some constructors * fix and add "with" / "add" methods
* add some constructors
} | ||
|
||
@Override() | ||
public CreateFunction addFunctionDeclarationParts(String... functionDeclarationParts) { |
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.
if we're just using super
does it make sense to override? Ah I guess this might be because we want it to return the specific type and not AnythingThat extends CreateFunctionStatement
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.
Yes, because it will be casted to CreateFunction
, the parent returns CreateFunctionalStatement
- the effect is, that the order of chaining does not matter, otherwise it would matter and the methods returning the parent or the super-class of the parent needs to be called at last in a chaining-context.
expressions.add(new JdbcParameter()); | ||
|
||
execute.withName(name) | ||
.withExecType(EXEC_TYPE.EXEC).withParenthesis(true) |
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.
super nit we probably should have kept EXEC_TYPE.EXECUTE just so the assertion didn't change?
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.
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.
That is a huge pull request. +1
You should not change existing tests. For instance you replaced the "old" variant of getting some parameter with the new, but both should be tested.
} | ||
} | ||
} | ||
/* |
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 is this file completely replaced? Are there some kind of linefeed differences?
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.
324ccf1
tried to replace formatchanges, that compare finds matching lines
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.
0d434b8
seems that the original commit had different linefeeds than the other files in this project
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',m sorry, did't work for this diff-view
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 think that was me. I work on a Mac and on a windows device from time to time. I’ll double check that we have a gitatttrbutes setup correctly to avoid these issues!
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.
Unfortunately only the latest versions of jgit, if you are using this, are taking gitattributes into account. But that explains this. If the file was wrong, now it would be corrected. So all fine.
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.
AH, I use intellij, so i bet my Windows gitbash auto-core config crap wasn't setup right.
super("FUNCTION", functionDeclarationParts); | ||
} | ||
|
||
@Override() |
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.
Could you remove this brackets on a simple override?
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.
ok, 9865783
@Test | ||
public void testAlterOnlyIssue928() throws JSQLParserException { | ||
assertSqlCanBeParsedAndDeparsed("ALTER TABLE ONLY categories ADD CONSTRAINT pk_categories PRIMARY KEY (category_id)"); | ||
String statement = "ALTER TABLE ONLY categories ADD CONSTRAINT pk_categories PRIMARY KEY (category_id)"; |
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.
Don't replace existing tests. Create new tests.
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.
normally I would agree to the principle of not changing tests, but didn't change the assert, but extending it with additional asserts.
doesn't it make sense to check parsing/deparsing, creation of the model and comparing it against the parsed model all together?
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.
But for instance you changed on various places the getExpression() to getExpression(Classtype).
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.
For the rest you wrote I agree.
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.
getExpression(Classtype) calls getExpression() inside. I changed it if explicit casting was done within testcase.
@@ -52,6 +89,13 @@ public void testMultiPartTableNameWithServerNameAndDatabaseNameAndSchemaName() t | |||
final String statement = "SELECT columnName FROM [server-name\\server-instance].databaseName.schemaName.tableName"; | |||
assertSqlCanBeParsedAndDeparsed(statement, false, | |||
parser -> parser.withSquareBracketQuotation(true)); | |||
assertDeparse(new Select().withSelectBody(new PlainSelect() |
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.
Don't change existing tests in this way. Create new tests.
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.
Please have a look to the comment above at AlterTest.java
|
||
executeDeParser.deParse(execute); | ||
|
||
String actual = buffer.toString(); | ||
assertTrue(actual.matches("EXECUTE " + name + " .*?, .*")); | ||
assertEquals("EXEC " + name + " (?, ?)", actual); |
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.
Here the outcome is suddenly EXEC not EXECUTE. 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.
reverted it to be EXEC - see #1014 (comment) too
…r.git into master.fluent
* fix RandomUtils to support enums * fix RandomUtils to map objects by its interfaces and super-classes * filter method "setASTNode" - do not test setters (cannot randomly create a SimpleNode)
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.
So far it looks good.
As always I merge using squash and merge for multi commit pull requests. If you want to squash it yourself, you are free to do so. One commit pull requests are merged normally. |
No objections if you want to sqash into one commit. The summary in the first comment of this merge request would be an appropriate comment for this commit. |
@wumpz it's ready to merge! |
Sorry. I am out of business for some days. Will merge if I am back |
So back on business. After I merged some other PRs you have some conflicts here. Please resolve those first. After this, I will merge. This PR was so far mergeable, right? Or do you want to add anything more? |
ok, i'v resolved the conflicts, it's ready to merge again. thanks in advance. |
I am sorry, it took a while. I will change the version number to reflect this large change. |
* JSQLParser#1004 * create(...) methods * chaining - methods returning "this" * overwrite chaining - methods of abstract parents/interfaces for returning concrete type * add<Name> methods on collection-fields with varargs-parameter * add public T get<Name>(Class<T>) - casting and returning an inner interface-type * 1004 add chaining - methods returning "this" * JSQLParser#1004 add chaining - methods returning "this" * * add<Name> methods on collection-fields with varargs-parameter * add<Name> methods on collection-fields with collection-parameter JSQLParser#1004 * * add chaining - methods returning "this" * add<Name> methods on collection-fields with varargs-parameter * add<Name> methods on collection-fields with collection-parameter JSQLParser#1004 * * add public T get<Name>(Class<T>) - casting and returning the concrete type JSQLParser#1004 * * add public T get<Name>(Class<T>) - casting and returning the concrete type (swap Class<? extends E> for Class<E>) JSQLParser#1004 * * overwrite chaining - methods of abstract parents/interfaces for returning concrete type JSQLParser#1004 * * add with prefix for fluent setters. JSQLParser#1004 * add getters * * add with prefix for fluent setters. (revert to chaining setters, do not break current api) JSQLParser#1004 * * add with prefix for fluent setters. (revert to chaining setters, do not break current api) JSQLParser#1004 * use new methods within testcases * use new methods within testcases * use new methods within testcases * use new methods within testcases * use new methods within testcases * use new methods within testcases * use new methods within testcases * use new methods within testcases * remove create() methods - they do not add enough value to be justified * * use new methods within testcases * add some constructors * fix and add "with" / "add" methods * * use new methods within testcases * * use new methods within testcases * add some constructors * * renamed constant * use new methods within testcases * use new methods within testcases * use new methods within testcases * use new methods within testcases * * use new methods within testcases * add some with-methods * add getter/setter named after the field without abbrivation * * use new methods within testcases * remove empty implicit constructor * return the deparsed Statement - object * compare object tree * compare object tree * * fix ObjectTreeToStringStyle * compare object tree * remove casts not needed * * use new methods within testcases * add some "set" "with" "add" methods missing * * use new methods within testcases * add empty constructors and override with-/add-methods returning concrete type * * add ReflectionModelTest * * use new methods within testcases * fix checkstyle errors * license header * remove test-classes from ReflectionModelTest * remove visitoradapter-classes from ReflectionModelTest * remove duplicate import declaration (checkstyle error) * * fix RandomUtils to support used java.sql.* types * fix RandomUtils to support enums * fix RandomUtils to map objects by its interfaces and super-classes * filter method "setASTNode" - do not test setters (cannot randomly create a SimpleNode) * add javadoc, stating that this is a marker interface JSQLParser#1014 (comment) * revert formatting change JSQLParser#1014 (comment) * change to EXEC_TYPE.EXECUTE just so the assertion didn't change JSQLParser#1014 (comment) * try to revert format changes JSQLParser#1014 (comment) * try to revert format changes JSQLParser#1014 (comment) * remove brackets on @OverRide() -> @OverRide * add with-methods to new fields
#1004
except for the create methods all changes are committed.
Further the chaining api is used