-
-
Notifications
You must be signed in to change notification settings - Fork 3.7k
modernize code using java 17 syntax #10889
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
base: main
Are you sure you want to change the base?
Conversation
Thanks for your pull request! This pull request does not follow the contribution rules. Could you have a look? ❌ All commit messages should start with a JIRA issue key matching pattern › This message was automatically generated. |
//note: datediff() is backwards on CUBRID | ||
case DAY: | ||
//note: datediff() is backwards on CUBRID |
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 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.
ah no ! will revert it
else { | ||
return super.castPattern( from, to ); | ||
} | ||
return super.castPattern( from, to ); |
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 not a fan of this style.
else { | ||
return this; | ||
} | ||
return this; |
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.
See above. Not personally a fan.
else { | ||
return " limit " + firstParameter; | ||
} | ||
return " limit " + firstParameter; |
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.
Ditto. If anything I would change stuff like this to use the ... ? ... : ....
operator.
else { | ||
return " top " + firstParameter; | ||
} | ||
return " top " + firstParameter; |
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.
Another case for ?:
, IMO.
else { | ||
return " rows " + firstParameter; | ||
} | ||
return " rows " + firstParameter; |
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.
Ditto.
final int selectOffset = Keyword.SELECT.rootOffset( sql ); | ||
final int afterSelectOffset = Keyword.SELECT.endOffset( sql, selectOffset ); | ||
final int fromOffset = Keyword.FROM.rootOffset( sql ); //TODO: what if there is no 'from' clause?! | ||
final var selectOffset = Keyword.SELECT.rootOffset( sql ); | ||
final var afterSelectOffset = Keyword.SELECT.endOffset( sql, selectOffset ); | ||
final var fromOffset = Keyword.FROM.rootOffset( sql ); //TODO: what if there is no 'from' clause?! | ||
|
||
boolean hasCommonTables = Keyword.WITH.occursAt( sql, 0 ); | ||
boolean hasOrderBy = Keyword.ORDER_BY.rootOffset( sql ) > 0; | ||
boolean hasFirstRow = hasFirstRow( limit ); | ||
var hasCommonTables = Keyword.WITH.occursAt( sql, 0 ); | ||
var hasOrderBy = Keyword.ORDER_BY.rootOffset( sql ) > 0; | ||
var hasFirstRow = hasFirstRow( limit ); |
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 think there's any benefit to changing int
or boolean
to var
. Let's not use var
for primitive types.
} | ||
else { | ||
final int firstPosition = jdbcParameterCount + 1 + ( topAdded ? 1 : 0 ); | ||
final var firstPosition = jdbcParameterCount + 1 + ( topAdded ? 1 : 0 ); |
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.
ditto.
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, thanks.
Many of these changes I like, but:
- I'm not at all a fan of getting rid of
else
everywhere. To me this just disrupts the symmetry of the code. I meanfalse
andtrue
are symmetric, why shouldtrue
be more nested? I do, on the other hand, like the?:
operator, which feels more "functional" to me. - I have not generally been replacing everything with
var
. I'm usually just doing it for longer type names and especially generic types. I definitely don't want to go through the whole code base and replace primitives,String
,Integer
, andObject
withvar
everywhere. That just doesn't buy us anything, really. So for consistency, I would prefer that we avoidvar
in those "trivial" cases. - I have not been writing
instanceof final
because it has too much tendency to make longif
conditions even longer. For consistency across the code base, let's stick with justinstanceof
.
55140f5
to
e968b15
Compare
3b31d77
to
2b44e52
Compare
2b44e52
to
fc485f3
Compare
Dear @gavinking , Thank you for the attention you gave to this PR and sorry for the extra mental load it might have caused.
Thanks @gavinking 🙏 |
Hello,
This PR is about some changes to use jdk 17 syntaxe (no behavioral change).
Just a contribution to give a hand with ongoing codebase cleanup work 👍
Thanks
By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license
and can be relicensed under the terms of the LGPL v2.1 license in the future at the maintainers' discretion.
For more information on licensing, please check here.