-
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
optimize: refactor InsertExecutor #2280
Conversation
Codecov Report
@@ Coverage Diff @@
## develop #2280 +/- ##
=============================================
- Coverage 50.91% 50.85% -0.06%
- Complexity 2815 2827 +12
=============================================
Files 558 561 +3
Lines 17941 17965 +24
Branches 2129 2102 -27
=============================================
+ Hits 9134 9136 +2
+ Misses 7938 7931 -7
- Partials 869 898 +29
|
please restore UpdateExecutorTest.java, SelectForUpdateExecutorTest.java, PlainExecutorTest.java and DeleteExecutorTest.java. |
@zjinlei fix done. |
...atasource/src/main/java/io/seata/rm/datasource/exec/postgresql/PostgresqlInsertExecutor.java
Outdated
Show resolved
Hide resolved
base on #2301 |
rm-datasource/src/main/java/io/seata/rm/datasource/exec/ExecuteTemplate.java
Outdated
Show resolved
Hide resolved
sqlparser/seata-sqlparser-core/src/main/java/io/seata/sqlparser/struct/SqlDefaultExpr.java
Outdated
Show resolved
Hide resolved
rm-datasource/src/main/java/io/seata/rm/datasource/exec/ExecuteTemplate.java
Outdated
Show resolved
Hide resolved
rm-datasource/src/main/java/io/seata/rm/datasource/exec/mysql/MySQLInsertExecutor.java
Show resolved
Hide resolved
sqlparser/seata-sqlparser-core/src/main/java/io/seata/sqlparser/struct/Defaultable.java
Show resolved
Hide resolved
rm-datasource/src/main/java/io/seata/rm/datasource/exec/InsertExecutor.java
Show resolved
Hide resolved
rm-datasource/src/main/java/io/seata/rm/datasource/exec/BaseInsertExecutor.java
Outdated
Show resolved
Hide resolved
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
} | ||
} | ||
} | ||
} |
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.
Reduce coupling and implement in 3 steps
1.getInsertRows
2.get pkIndex list from rows
3.get pkValue list from parameters
rm-datasource/src/main/java/io/seata/rm/datasource/exec/oracle/OracleInsertExecutor.java
Show resolved
Hide resolved
...atasource/src/main/java/io/seata/rm/datasource/exec/postgresql/PostgresqlInsertExecutor.java
Show resolved
Hide resolved
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, Test Passed.
MYSQL
insert into account_tbl(user_id, money, information) values (?, ?, ?)
insert into account_tbl(id, user_id, money, information) values (?, ?, ?, ?)
insert into account_tbl(id, user_id, money, information) values (null, ?, ?, ?)
ORACLE
insert into account_tbl(id, user_id, money, information, description) values (1, ?, ?, ?, ?)
insert into account_tbl(id, user_id, money, information, description) values (?, ?, ?, ?, ?)
insert into account_tbl(id, user_id, money, information, description) values (account_tbl_seq.nextval, ?, ?, ?, ?)
POSTGRE
insert into account_tbl(id, user_id, money) values (1, trim(both ?), ?)
insert into account_tbl(id, user_id, money) values (?, trim(both ?), ?)
insert into account_tbl(id, user_id, money) values (nextval('seq_account_tbl_id'), trim(both ?), ?)
Codecov Report
@@ Coverage Diff @@
## develop #2280 +/- ##
=============================================
+ Coverage 51.05% 51.13% +0.08%
- Complexity 2835 2849 +14
=============================================
Files 563 566 +3
Lines 18047 18072 +25
Branches 2138 2141 +3
=============================================
+ Hits 9214 9242 +28
+ Misses 7951 7944 -7
- Partials 882 886 +4
|
Ⅰ. Describe what this PR did
Refactor insert executor.
Ⅱ. Does this pull request fix one issue?
fixes #2042
Ⅲ. Why don't you add test cases (unit test/integration test)?
Ⅳ. Describe how to verify it
Ⅴ. Special notes for reviews