-
-
Notifications
You must be signed in to change notification settings - Fork 2.6k
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
Batch remove entries #5659
Batch remove entries #5659
Conversation
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.
LGTM. Thank you for following-up.
@@ -164,18 +164,46 @@ void testUpdateEqualEntry(DBMSType dbmsType, DBMSConnection dbmsConnection, DBMS | |||
|
|||
@ParameterizedTest | |||
@MethodSource("org.jabref.logic.shared.TestManager#getTestingDatabaseSystems") | |||
void testRemoveEntry(DBMSType dbmsType, DBMSConnection dbmsConnection, DBMSProcessor dbmsProcessor) throws SQLException { |
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.
Can be keep the single test? -> Meaning the additional test for two entries is OK, but we should also keep the simple (and probably always succeeding test). - Reason: The for loop above is not entered for one entry and thus this test case is special.
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 could, but it would still have to be dbmsProcessor.removeEntries(Collections.singletonList(entryToRemove))
because I got rid of DBMSProcessor.removeEntry
in the singular. Is it still worth it?
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.
Sure. The tests should be independent of the implemention somehow. Tests should cover the general case, but also edge cases, null list, 0 element list, list with 1 elements, list with integer.max elements (which is impossible IMHO), but the other cases should be easy to do?
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.
Okay, in that case I will use Collections.singletonList
. Should I add a test for each of those edge cases as well?
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.
Sure, please go ahead. In case tests are easy to write, they should be written. - The thing is: The implementation could change in 1 year (who knows) and the test will still cover that case.
Please also add a test for
dbmsProcessor.removeEntries(Collections.emptyList())
dbmsProcessor.removeEntries(null)
(should throw a NPE)
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.
Throw on empty list? If so, throw what? I can't imagine why someone would want to call removeEntries
on purpose on an empty list.
Minor thing: checkstyle should be fixed 😇 |
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.
Just a minor suggestion, otherwise looks very good to me! Thanks
.append(" = ?"); | ||
.append(" IN ("); | ||
for (int i = 0; i < bibEntries.size() - 1; i++) { | ||
query.append("?, "); |
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 you can use "?, "
.repeat(bibEntries.size())` here
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.
Made the change, will push soon.
I merged to move ahead. Think, the software engineering discussion can be done later :)
https://sqa.stackexchange.com/a/9009/28592 Thus, I argue for improper usage - who knows, what future code will bring. |
Thanks! Is there any way I can fix this in my following PR? |
I changed the SQL in
DBMSProcessor
so that multiple entries are deleted with one query instead of using a query for each entry. This was the original rationale for the refactoring I did in October.