Added: SQL builder toString function#730
Conversation
vorburger
left a comment
There was a problem hiding this comment.
After this PR, I intend to write proper test statements as required.
If I may be a pain 😈 it is typically considered much better practice to do something like this and have the test in the same PR.. in this particular case, just commenting out the x3 related TODO in SQLBuilderTest.java as part of this PR would be great.
There was a problem hiding this comment.
| StringBuilder whereClause = new StringBuilder(); | |
| StringBuilder whereClause = new StringBuilder("SQLBuilder{ "); |
There was a problem hiding this comment.
| return "SQLBuilder{"+ whereClause.toString() +"}"; | |
| whereClause.append(" }"); | |
| return whereClause.toString(); |
The point of this is to avoid unnecessary String concatenation object creation.
You should also avoid any other String + in this method - just append() everything.
There was a problem hiding this comment.
you can probably avoid creating this intermediate list? Just iterate and append to the StringBuilder, no? Or perhaps I'm missing something here (quick review only; didn't read the code in full details).
|
Thank you for the review, working on the required changes. |
3d87262 to
1be08bb
Compare
vorburger
left a comment
There was a problem hiding this comment.
Great! Minor feedback, if you want to further optimize? Just for the fun of it... ;-)
PS: Also formatting is non-standard, but I can't hold that against you so won't be a pain, let's ignore; it will all get bulk re-formatted at some future point (what we really need is more Checkstyle.. want to help with that?)
There was a problem hiding this comment.
I think you could still save this StringBuilder and just whereClause.append(...) as you go? Just a thought.
|
@vorburger No pain, I am willing to learn the correct way( I plan to stay with fineract for long :P)
|
vorburger
left a comment
There was a problem hiding this comment.
LGTM! I'll merge when build passed.
|
PS re Checkstyle, see https://issues.apache.org/jira/browse/FINERACT-821, as per https://lists.apache.org/thread.html/r40d39423999b55a4ac2fa96aba0a16b91f80ac9f8e4ecb4c372c61c8%40%3Cdev.fineract.apache.org%3E (also on https://markmail.org/message/hk42ip7feruoaooo), gradually fixing formatting problems allowing to enable new rules in https://github.com/apache/fineract/blob/develop/fineract-provider/config/checkstyle/checkstyle.xml is the way to go. |
Description
To continue to work done in #725 by @vorburger this PR intends to complete one of the remaining tasks.
Please use the following for functional testing: http://tpcg.io/QfG1joot [outdated] (directly run for sample output)
After this PR, I intend to write proper test statements as required.
Note: Another approach could have been directly using sb, I decided to do it this way any suggestions are welcome :)
Checklist
Please make sure these boxes are checked before submitting your pull request - thanks!
Commit message starts with the issue number from https://issues.apache.org/jira/projects/FINERACT/. Ex: FINERACT-646 Pockets API.
Coding conventions at https://cwiki.apache.org/confluence/display/FINERACT/Coding+Conventions have been followed.
API documentation at https://github.com/apache/fineract/blob/develop/api-docs/apiLive.htm has been updated with details of any API changes.
Integration tests have been created/updated for verifying the changes made.
All Integrations tests are passing with the new commits.
Submission is not a "code dump". (Large changes can be made "in repository" via a branch. Ask on the list.)
Our guidelines for code reviews is at https://cwiki.apache.org/confluence/display/FINERACT/Code+Review+Guide