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 the column TINYINT(1) in MySql being resolved to BIT type #6068

Closed
wants to merge 15 commits into from

Conversation

wangliang181230
Copy link
Contributor

@wangliang181230 wangliang181230 commented Nov 21, 2023

Same as #6070 commits into the branch 2.x

@wangliang181230 wangliang181230 requested review from funky-eyes and slievrly and removed request for funky-eyes November 21, 2023 06:24
@wangliang181230 wangliang181230 added this to the 1.8.1 milestone Nov 21, 2023
Copy link

codecov bot commented Nov 21, 2023

Codecov Report

Merging #6068 (6fadf7f) into develop (c0c8725) will increase coverage by 0.05%.
The diff coverage is 51.00%.

Additional details and impacted files

Impacted file tree graph

@@              Coverage Diff              @@
##             develop    #6068      +/-   ##
=============================================
+ Coverage      48.86%   48.92%   +0.05%     
- Complexity      4182     4191       +9     
=============================================
  Files            793      795       +2     
  Lines          28039    28085      +46     
  Branches        3426     3432       +6     
=============================================
+ Hits           13701    13740      +39     
- Misses         12901    12905       +4     
- Partials        1437     1440       +3     
Files Coverage Δ
...seata/core/context/FastThreadLocalContextCore.java 85.71% <ø> (ø)
.../datasource/sql/struct/cache/DmTableMetaCache.java 83.14% <100.00%> (ø)
...source/sql/struct/cache/MariadbTableMetaCache.java 77.77% <100.00%> (ø)
...asource/sql/struct/cache/OracleTableMetaCache.java 67.30% <100.00%> (ø)
...rce/sql/struct/cache/PostgresqlTableMetaCache.java 74.72% <100.00%> (ø)
...ource/sql/struct/cache/PolarDBXTableMetaCache.java 11.11% <0.00%> (ø)
...seata/rm/datasource/undo/AbstractUndoExecutor.java 69.65% <80.00%> (+0.42%) ⬆️
...in/java/io/seata/sqlparser/util/JdbcConstants.java 0.00% <0.00%> (ø)
.../io/seata/common/loader/EnhancedServiceLoader.java 58.67% <78.57%> (+1.59%) ⬆️
...ava/io/seata/common/loader/DependsOnException.java 33.33% <33.33%> (ø)
... and 3 more

... and 5 files with indirect coverage changes

@slievrly slievrly added the Do Not Merge Do not merge into develop label Nov 21, 2023
// JDBCType.DISTINCT, JDBCType.STRUCT etc...
field.setValue(holdSerialDataType(resultSet.getObject(i)));
}
loadFieldValue(field, resultSet, i);
Copy link
Contributor

Choose a reason for hiding this comment

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

这个方法都抽离出去独立了,不如把212行的代码也挪过去吧,增加一个dataType的入参
Since this method has been extracted and made independent, why not move the code from line 212 as well and add a dataType parameter

Copy link
Contributor Author

@wangliang181230 wangliang181230 Nov 24, 2023

Choose a reason for hiding this comment

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

我觉得没必要吧。对于 loadFieldValue 方法来说,它不应该负责 setDataType 的。

Copy link
Contributor

@funky-eyes funky-eyes Nov 24, 2023

Choose a reason for hiding this comment

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

但是loadfieldvalue中你又进行了一次getdatatype,这样合适吗?
But in loadFieldValue, you are doing another getDataType() call. Is that appropriate?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

loadFieldValue的实现,是通过dataType来判断,去加载value,这很合理啊。
但是loadFieldValue方法的调用方,单从方法名上看,就无法理解为什么要把setDataType放到这个方法中。

Copy link
Contributor

Choose a reason for hiding this comment

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

loadFieldValue的实现,是通过dataType来判断,去加载value,这很合理啊。 但是loadFieldValue方法的调用方,单从方法名上看,就无法理解为什么要把setDataType放到这个方法中。

那你的方法名是不是应该修改下?你也说了loadFieldValue依赖dataType
Then should you modify your method name? You also mentioned that loadFieldValue depends on dataType.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

调用方,又不用关心它是怎么实现的,只要知道这个方法是加载value的就行了啊。

Copy link
Contributor Author

Choose a reason for hiding this comment

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

你在定义一个接口的方法名的时候,你会去考虑实现方式来定方法名吗?肯定不会吧。

Copy link
Contributor

Choose a reason for hiding this comment

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

调用方,又不用关心它是怎么实现的,只要知道这个方法是加载value的就行了啊。

谁在调用?除了这还有哪里?
Who is calling it? Are there any other places besides this?

Copy link
Contributor

Choose a reason for hiding this comment

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

loadFieldValue 依赖dataType,结果也不进行传参,到里面了get一下,我理解不了这么写的写法。如果方法名觉得不直观可以改,loadfieldvalue只服务于buildRecords

@@ -38,7 +38,7 @@ protected TableMeta fetchSchema(Connection connection, String tableName) throws
String sql = "SELECT * FROM " + ColumnUtils.addEscape(tableName, JdbcConstants.MARIADB) + " LIMIT 1";
try (Statement stmt = connection.createStatement();
ResultSet rs = stmt.executeQuery(sql)) {
return resultSetMetaToSchema(rs.getMetaData(), connection.getMetaData());
return resultSetMetaToSchema(connection, stmt, rs, rs.getMetaData(), connection.getMetaData());
Copy link
Contributor

Choose a reason for hiding this comment

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

为什么要增加rs.getMetaData(), connection.getMetaData()多个入参,在拥有rs,和connection后,本身就可以再内部获取
Why add multiple parameters for rs.getMetaData() and connection.getMetaData() when we can already obtain them internally once we have rs and connection?

Copy link
Contributor Author

@wangliang181230 wangliang181230 Nov 24, 2023

Choose a reason for hiding this comment

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

更直接的体现给想要实现该接口的开发者。并不是所有开发人员都知道,可以从metadata中,获取到rs嘛。降低门槛。

Copy link
Contributor

Choose a reason for hiding this comment

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

更直接的体现给想要实现该接口的开发者。并不是所有开发人员都知道,可以从metadata中,获取到rs嘛。降低门槛。

我的意思是在resultSetMetaToSchema方法中单独获取,难道这样换个地方get开发者就看不明白了吗?
What I mean is to obtain it separately in the resultSetMetaToSchema method. Does it mean that developers will not understand it if we get it from a different place?

@@ -145,7 +156,14 @@ protected TableMeta resultSetMetaToSchema(ResultSetMetaData rsmd, DatabaseMetaDa
if (tm.getAllColumns().containsKey(col.getColumnName())) {
throw new NotSupportYetException("Not support the table has the same column name with different case yet");
}

for (IColumnMetaProcessor processor : processors) {
processor.process(col, columnIndex, context);
Copy link
Contributor

Choose a reason for hiding this comment

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

为什么我们需要多个processor都运行,我认为一个足以?如果有多个,反而可能造成混乱的结果。而且我认为process应该按照当前datasource的dbtype进行加载,否则在用户有多个db数据源下会出现异常
Why do we need multiple processors to run? I think one is sufficient. If there are multiple processors, it might actually lead to confusing results. Moreover, I believe the processes should be loaded based on the current datasource's DB type; otherwise, it may cause exceptions when the user has multiple DB data sources.

@@ -26,7 +26,7 @@
*
* @author ph3636
*/
@LoadLevel(name = "FastThreadLocalContextCore", order = Integer.MIN_VALUE + 1)
@LoadLevel(name = "FastThreadLocalContextCore", order = Integer.MIN_VALUE + 1, dependsOnClasses = FastThreadLocal.class)
Copy link
Contributor

Choose a reason for hiding this comment

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

为什么要把不想干的代码一起改了?
Why did you change the unrelated code together?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Do Not Merge Do not merge into develop
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants