-
Notifications
You must be signed in to change notification settings - Fork 8.7k
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
Do data validation when undo. #1060
Conversation
I will add more test case which uses h2 database later. |
Codecov Report
@@ Coverage Diff @@
## develop #1060 +/- ##
=============================================
+ Coverage 39.44% 39.94% +0.49%
- Complexity 1138 1153 +15
=============================================
Files 222 222
Lines 8872 8929 +57
Branches 1143 1158 +15
=============================================
+ Hits 3500 3567 +67
+ Misses 4931 4914 -17
- Partials 441 448 +7
Continue to review full report at Codecov.
|
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
// parese pk values | ||
Object[] pkValues = parsePkValues(getUndoRows()); | ||
|
||
PreparedStatement statement = conn.prepareStatement(checkSQL); |
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 statement should close in finally .
*/ | ||
protected void dataValidation(Connection conn) throws SQLException { | ||
protected boolean dataValidation(Connection conn) 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.
It ‘s better to add a switcher to close the dirty data check manually, the switcher is open default.
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, I will add it in the next standalone PR.
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 left some comments
executor.executeOn(new MockConnection()); | ||
// skip data validation | ||
Mockito.doReturn(true).when(spy).dataValidation(connection); | ||
spy.executeOn(connection); | ||
} catch (SQLException e) { | ||
e.printStackTrace(); |
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 use e.printTrace()
executor.executeOn(new MockConnection()); | ||
// skip data validation | ||
Mockito.doReturn(true).when(spy).dataValidation(connection); | ||
spy.executeOn(connection); | ||
} catch (SQLException e) { | ||
e.printStackTrace(); |
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 use e.printTrace()
// no need undo if the before data snapshot is equivalent to the after data snapshot. | ||
if (DataCompareUtils.isRecordsEquals(sqlUndoLog.getBeforeImage(), sqlUndoLog.getAfterImage())) { | ||
// when the data validation is not ok | ||
if (!dataValidation(conn)) { | ||
return; |
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.
should we throw some exception explicitly for the code change later?
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.
Sorry, I don’t get your point.
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 add some log and change the method name for more explicitly.
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.
as communicated offline
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.
@leizhiyuan done.
* Do data validation when undo. * Run test case use h2 database. * fix as review. * Add log.
Ⅰ. Describe what this PR did
Ⅱ. Does this pull request fix one issue?
Part of #1049