Skip to content
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

bugfix: fix could not rollback when insert the table with multiple key #6077

Merged
merged 20 commits into from
Dec 5, 2023

Conversation

l81893521
Copy link
Contributor

@l81893521 l81893521 commented Nov 23, 2023

  • I have registered the PR changes.

Ⅰ. Describe what this PR did

Ⅱ. Does this pull request fix one issue?

fixes #6076

Ⅲ. Why don't you add test cases (unit test/integration test)?

Ⅳ. Describe how to verify it

Ⅴ. Special notes for reviews

@funky-eyes funky-eyes self-assigned this Nov 23, 2023
@funky-eyes funky-eyes added this to the 2.1.0 milestone Nov 23, 2023
Copy link

codecov bot commented Nov 23, 2023

Codecov Report

Merging #6077 (b4bf7e9) into 2.x (f42fb72) will increase coverage by 0.09%.
The diff coverage is 94.11%.

Additional details and impacted files

Impacted file tree graph

@@             Coverage Diff              @@
##                2.x    #6077      +/-   ##
============================================
+ Coverage     49.29%   49.38%   +0.09%     
- Complexity     4800     4805       +5     
============================================
  Files           913      913              
  Lines         31677    31678       +1     
  Branches       3825     3826       +1     
============================================
+ Hits          15614    15645      +31     
+ Misses        14514    14487      -27     
+ Partials       1549     1546       -3     
Files Coverage Δ
.../rm/datasource/exec/BaseTransactionalExecutor.java 74.09% <94.11%> (+13.15%) ⬆️

... and 6 files with indirect coverage changes

* @param columnName the column name
* @return the column name in sql
*/
protected String getColumnNameInSQL(String columnName) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

为什么要移动这段代码位置?而不是在它后面增加新方法?
Why move this piece of code instead of adding the new method after it?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

because reordering the type of method it looks more beautiful.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

because reordering the type of method it looks more beautiful.

那为什么不是将getColumnNamesInSQLList 挪到上面?
So why not move getColumnNamesInSQLList to the top?

Copy link
Contributor Author

@l81893521 l81893521 Nov 28, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

3 method of getColumnNamesWithTablePrefix and 3 method of getColumnNameInSQL. I just put it together

@funky-eyes funky-eyes added type: bug Category issues or prs related to bug. module/rm-datasource rm-datasource module labels Nov 24, 2023
@@ -192,18 +192,6 @@ protected String buildLimitCondition(WhereRecognizer recognizer, ArrayList<List<
return limitCondition;
}

/**
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
/**
/**
* Gets column name in sql.
*
* @param columnName the column name
* @return the column name in sql
*/
protected String getColumnNameInSQL(String columnName) {
String tableAlias = sqlRecognizer.getTableAlias();
return tableAlias == null ? columnName : tableAlias + "." + columnName;
}
/**
* Gets column names in sql.
*
* @param columnNames the column names
* @return
*/
protected List<String> getColumnNamesInSQLList(List<String> columnNames) {
List<String> columnNameWithTableAlias = new ArrayList<>();
for (String columnName : columnNames) {
columnNameWithTableAlias.add(this.getColumnNameInSQL(columnName));
}
return columnNameWithTableAlias;
}

Comment on lines +245 to +257
/**
* Gets column name in sql.
*
* @param columnName the column name
* @return the column name in sql
*/
protected String getColumnNameInSQL(String columnName) {
String tableAlias = sqlRecognizer.getTableAlias();
return tableAlias == null ? columnName : tableAlias + "." + columnName;
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
/**
* Gets column name in sql.
*
* @param columnName the column name
* @return the column name in sql
*/
protected String getColumnNameInSQL(String columnName) {
String tableAlias = sqlRecognizer.getTableAlias();
return tableAlias == null ? columnName : tableAlias + "." + columnName;
}

Comment on lines +256 to +272
/**
* Gets column names in sql.
*
* @param columnNames the column names
* @return
*/
protected List<String> getColumnNamesInSQLList(List<String> columnNames) {
List<String> columnNameWithTableAlias = new ArrayList<>();
for (String columnName : columnNames) {
columnNameWithTableAlias.add(this.getColumnNameInSQL(columnName));
}
return columnNameWithTableAlias;
}

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
/**
* Gets column names in sql.
*
* @param columnNames the column names
* @return
*/
protected List<String> getColumnNamesInSQLList(List<String> columnNames) {
List<String> columnNameWithTableAlias = new ArrayList<>();
for (String columnName : columnNames) {
columnNameWithTableAlias.add(this.getColumnNameInSQL(columnName));
}
return columnNameWithTableAlias;
}

@l81893521 l81893521 force-pushed the bugfix_repeated_insert_columns branch from 4e1d3c9 to f00d469 Compare December 2, 2023 14:52
@funky-eyes funky-eyes added the mode: AT AT transaction mode label Dec 5, 2023
Copy link
Contributor

@funky-eyes funky-eyes left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
mode: AT AT transaction mode module/rm-datasource rm-datasource module type: bug Category issues or prs related to bug.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Could not rollback when insert the table with multiple key
2 participants