You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@shardingsphere.apache.org by GitBox <gi...@apache.org> on 2020/09/23 04:55:43 UTC

[GitHub] [shardingsphere] strongduanmu opened a new pull request #7573: migrate some methods in InsertStatement to InsertStatementContext

strongduanmu opened a new pull request #7573:
URL: https://github.com/apache/shardingsphere/pull/7573


   Ref #7170.
   
   Changes proposed in this pull request:
   - migrate some methods in InsertStatement to InsertStatementContext
   


----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [shardingsphere] coveralls edited a comment on pull request #7573: migrate some methods in InsertStatement to InsertStatementContext

Posted by GitBox <gi...@apache.org>.
coveralls edited a comment on pull request #7573:
URL: https://github.com/apache/shardingsphere/pull/7573#issuecomment-697152228


   ## Pull Request Test Coverage Report for [Build 15042](https://coveralls.io/builds/33698016)
   
   * **77** of **88**   **(87.5%)**  changed or added relevant lines in **24** files are covered.
   * **65** unchanged lines in **12** files lost coverage.
   * Overall coverage decreased (**-0.004%**) to **35.108%**
   
   ---
   
   |  Changes Missing Coverage | Covered Lines | Changed/Added Lines | % |
   | :-----|--------------|--------|---: |
   | [shardingsphere-features/shardingsphere-shadow/shardingsphere-shadow-rewrite/src/main/java/org/apache/shardingsphere/shadow/rewrite/parameter/impl/ShadowInsertValueParameterRewriter.java](https://coveralls.io/builds/33698016/source?filename=shardingsphere-features%2Fshardingsphere-shadow%2Fshardingsphere-shadow-rewrite%2Fsrc%2Fmain%2Fjava%2Forg%2Fapache%2Fshardingsphere%2Fshadow%2Frewrite%2Fparameter%2Fimpl%2FShadowInsertValueParameterRewriter.java#L37) | 0 | 1 | 0.0%
   | [shardingsphere-features/shardingsphere-shadow/shardingsphere-shadow-rewrite/src/main/java/org/apache/shardingsphere/shadow/rewrite/token/generator/impl/ShadowInsertValuesTokenGenerator.java](https://coveralls.io/builds/33698016/source?filename=shardingsphere-features%2Fshardingsphere-shadow%2Fshardingsphere-shadow-rewrite%2Fsrc%2Fmain%2Fjava%2Forg%2Fapache%2Fshardingsphere%2Fshadow%2Frewrite%2Ftoken%2Fgenerator%2Fimpl%2FShadowInsertValuesTokenGenerator.java#L48) | 0 | 1 | 0.0%
   | [shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-route/src/main/java/org/apache/shardingsphere/sharding/route/engine/condition/engine/InsertClauseShardingConditionEngine.java](https://coveralls.io/builds/33698016/source?filename=shardingsphere-features%2Fshardingsphere-sharding%2Fshardingsphere-sharding-route%2Fsrc%2Fmain%2Fjava%2Forg%2Fapache%2Fshardingsphere%2Fsharding%2Froute%2Fengine%2Fcondition%2Fengine%2FInsertClauseShardingConditionEngine.java#L78) | 0 | 1 | 0.0%
   | [shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-route/src/main/java/org/apache/shardingsphere/sharding/route/engine/validator/impl/ShardingDeleteStatementValidator.java](https://coveralls.io/builds/33698016/source?filename=shardingsphere-features%2Fshardingsphere-sharding%2Fshardingsphere-sharding-route%2Fsrc%2Fmain%2Fjava%2Forg%2Fapache%2Fshardingsphere%2Fsharding%2Froute%2Fengine%2Fvalidator%2Fimpl%2FShardingDeleteStatementValidator.java#L46) | 0 | 1 | 0.0%
   | [shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-route/src/main/java/org/apache/shardingsphere/sharding/route/engine/validator/impl/ShardingUpdateStatementValidator.java](https://coveralls.io/builds/33698016/source?filename=shardingsphere-features%2Fshardingsphere-sharding%2Fshardingsphere-sharding-route%2Fsrc%2Fmain%2Fjava%2Forg%2Fapache%2Fshardingsphere%2Fsharding%2Froute%2Fengine%2Fvalidator%2Fimpl%2FShardingUpdateStatementValidator.java#L75) | 0 | 1 | 0.0%
   | [shardingsphere-sql-parser/shardingsphere-sql-parser-binder/src/main/java/org/apache/shardingsphere/sql/parser/binder/segment/insert/keygen/engine/GeneratedKeyContextEngine.java](https://coveralls.io/builds/33698016/source?filename=shardingsphere-sql-parser%2Fshardingsphere-sql-parser-binder%2Fsrc%2Fmain%2Fjava%2Forg%2Fapache%2Fshardingsphere%2Fsql%2Fparser%2Fbinder%2Fsegment%2Finsert%2Fkeygen%2Fengine%2FGeneratedKeyContextEngine.java#L82) | 11 | 17 | 64.71%
   <!-- | **Total:** | **77** | **88** | **87.5%** | -->
   
   |  Files with Coverage Reduction | New Missed Lines | % |
   | :-----|--------------|--: |
   | [shardingsphere-sql-parser/shardingsphere-sql-parser-statement/src/main/java/org/apache/shardingsphere/sql/parser/sql/dialect/statement/oracle/dml/OracleInsertStatement.java](https://coveralls.io/builds/33698016/source?filename=shardingsphere-sql-parser%2Fshardingsphere-sql-parser-statement%2Fsrc%2Fmain%2Fjava%2Forg%2Fapache%2Fshardingsphere%2Fsql%2Fparser%2Fsql%2Fdialect%2Fstatement%2Foracle%2Fdml%2FOracleInsertStatement.java#L26) | 1 | 0% |
   | [shardingsphere-sql-parser/shardingsphere-sql-parser-statement/src/main/java/org/apache/shardingsphere/sql/parser/sql/dialect/statement/sql92/dml/SQL92InsertStatement.java](https://coveralls.io/builds/33698016/source?filename=shardingsphere-sql-parser%2Fshardingsphere-sql-parser-statement%2Fsrc%2Fmain%2Fjava%2Forg%2Fapache%2Fshardingsphere%2Fsql%2Fparser%2Fsql%2Fdialect%2Fstatement%2Fsql92%2Fdml%2FSQL92InsertStatement.java#L26) | 1 | 0% |
   | [shardingsphere-scaling/shardingsphere-scaling-core/src/main/java/org/apache/shardingsphere/scaling/core/exception/DataCheckFailException.java](https://coveralls.io/builds/33698016/source?filename=shardingsphere-scaling%2Fshardingsphere-scaling-core%2Fsrc%2Fmain%2Fjava%2Forg%2Fapache%2Fshardingsphere%2Fscaling%2Fcore%2Fexception%2FDataCheckFailException.java#L26) | 2 | 0% |
   | [shardingsphere-sql-parser/shardingsphere-sql-parser-statement/src/main/java/org/apache/shardingsphere/sql/parser/sql/common/statement/dml/InsertStatement.java](https://coveralls.io/builds/33698016/source?filename=shardingsphere-sql-parser%2Fshardingsphere-sql-parser-statement%2Fsrc%2Fmain%2Fjava%2Forg%2Fapache%2Fshardingsphere%2Fsql%2Fparser%2Fsql%2Fcommon%2Fstatement%2Fdml%2FInsertStatement.java#L64) | 2 | 40.0% |
   | [shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-rewrite/src/main/java/org/apache/shardingsphere/sharding/rewrite/token/generator/impl/ProjectionsTokenGenerator.java](https://coveralls.io/builds/33698016/source?filename=shardingsphere-features%2Fshardingsphere-sharding%2Fshardingsphere-sharding-rewrite%2Fsrc%2Fmain%2Fjava%2Forg%2Fapache%2Fshardingsphere%2Fsharding%2Frewrite%2Ftoken%2Fgenerator%2Fimpl%2FProjectionsTokenGenerator.java#L88) | 4 | 92.59% |
   | [shardingsphere-scaling/shardingsphere-scaling-bootstrap/src/main/java/org/apache/shardingsphere/scaling/web/HttpServerHandler.java](https://coveralls.io/builds/33698016/source?filename=shardingsphere-scaling%2Fshardingsphere-scaling-bootstrap%2Fsrc%2Fmain%2Fjava%2Forg%2Fapache%2Fshardingsphere%2Fscaling%2Fweb%2FHttpServerHandler.java#L87) | 4 | 86.36% |
   | [shardingsphere-scaling/shardingsphere-scaling-postgresql/src/main/java/org/apache/shardingsphere/scaling/postgresql/PostgreSQLDataConsistencyChecker.java](https://coveralls.io/builds/33698016/source?filename=shardingsphere-scaling%2Fshardingsphere-scaling-postgresql%2Fsrc%2Fmain%2Fjava%2Forg%2Fapache%2Fshardingsphere%2Fscaling%2Fpostgresql%2FPostgreSQLDataConsistencyChecker.java#L34) | 4 | 0% |
   | [shardingsphere-infra/shardingsphere-infra-executor/src/main/java/org/apache/shardingsphere/infra/executor/sql/context/ExecutionContextBuilder.java](https://coveralls.io/builds/33698016/source?filename=shardingsphere-infra%2Fshardingsphere-infra-executor%2Fsrc%2Fmain%2Fjava%2Forg%2Fapache%2Fshardingsphere%2Finfra%2Fexecutor%2Fsql%2Fcontext%2FExecutionContextBuilder.java#L91) | 5 | 85.37% |
   | [shardingsphere-scaling/shardingsphere-scaling-core/src/main/java/org/apache/shardingsphere/scaling/core/check/AbstractDataConsistencyChecker.java](https://coveralls.io/builds/33698016/source?filename=shardingsphere-scaling%2Fshardingsphere-scaling-core%2Fsrc%2Fmain%2Fjava%2Forg%2Fapache%2Fshardingsphere%2Fscaling%2Fcore%2Fcheck%2FAbstractDataConsistencyChecker.java#L69) | 6 | 76.92% |
   | [shardingsphere-scaling/shardingsphere-scaling-core/src/main/java/org/apache/shardingsphere/scaling/core/ScalingJobController.java](https://coveralls.io/builds/33698016/source?filename=shardingsphere-scaling%2Fshardingsphere-scaling-core%2Fsrc%2Fmain%2Fjava%2Forg%2Fapache%2Fshardingsphere%2Fscaling%2Fcore%2FScalingJobController.java#L102) | 7 | 76.47% |
   <!-- | **Total:** | **65** |  | -->
   
   |  Totals | [![Coverage Status](https://coveralls.io/builds/33698016/badge)](https://coveralls.io/builds/33698016) |
   | :-- | --: |
   | Change from base [Build 15013](https://coveralls.io/builds/33680530): |  -0.004% |
   | Covered Lines: | 36625 |
   | Relevant Lines: | 104322 |
   
   ---
   ##### 💛  - [Coveralls](https://coveralls.io)
   


----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [shardingsphere] coveralls edited a comment on pull request #7573: migrate some methods in InsertStatement to InsertStatementContext

Posted by GitBox <gi...@apache.org>.
coveralls edited a comment on pull request #7573:
URL: https://github.com/apache/shardingsphere/pull/7573#issuecomment-697152228


   ## Pull Request Test Coverage Report for [Build 15042](https://coveralls.io/builds/33698016)
   
   * **77** of **88**   **(87.5%)**  changed or added relevant lines in **24** files are covered.
   * **65** unchanged lines in **12** files lost coverage.
   * Overall coverage decreased (**-0.004%**) to **35.108%**
   
   ---
   
   |  Changes Missing Coverage | Covered Lines | Changed/Added Lines | % |
   | :-----|--------------|--------|---: |
   | [shardingsphere-features/shardingsphere-shadow/shardingsphere-shadow-rewrite/src/main/java/org/apache/shardingsphere/shadow/rewrite/parameter/impl/ShadowInsertValueParameterRewriter.java](https://coveralls.io/builds/33698016/source?filename=shardingsphere-features%2Fshardingsphere-shadow%2Fshardingsphere-shadow-rewrite%2Fsrc%2Fmain%2Fjava%2Forg%2Fapache%2Fshardingsphere%2Fshadow%2Frewrite%2Fparameter%2Fimpl%2FShadowInsertValueParameterRewriter.java#L37) | 0 | 1 | 0.0%
   | [shardingsphere-features/shardingsphere-shadow/shardingsphere-shadow-rewrite/src/main/java/org/apache/shardingsphere/shadow/rewrite/token/generator/impl/ShadowInsertValuesTokenGenerator.java](https://coveralls.io/builds/33698016/source?filename=shardingsphere-features%2Fshardingsphere-shadow%2Fshardingsphere-shadow-rewrite%2Fsrc%2Fmain%2Fjava%2Forg%2Fapache%2Fshardingsphere%2Fshadow%2Frewrite%2Ftoken%2Fgenerator%2Fimpl%2FShadowInsertValuesTokenGenerator.java#L48) | 0 | 1 | 0.0%
   | [shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-route/src/main/java/org/apache/shardingsphere/sharding/route/engine/condition/engine/InsertClauseShardingConditionEngine.java](https://coveralls.io/builds/33698016/source?filename=shardingsphere-features%2Fshardingsphere-sharding%2Fshardingsphere-sharding-route%2Fsrc%2Fmain%2Fjava%2Forg%2Fapache%2Fshardingsphere%2Fsharding%2Froute%2Fengine%2Fcondition%2Fengine%2FInsertClauseShardingConditionEngine.java#L78) | 0 | 1 | 0.0%
   | [shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-route/src/main/java/org/apache/shardingsphere/sharding/route/engine/validator/impl/ShardingDeleteStatementValidator.java](https://coveralls.io/builds/33698016/source?filename=shardingsphere-features%2Fshardingsphere-sharding%2Fshardingsphere-sharding-route%2Fsrc%2Fmain%2Fjava%2Forg%2Fapache%2Fshardingsphere%2Fsharding%2Froute%2Fengine%2Fvalidator%2Fimpl%2FShardingDeleteStatementValidator.java#L46) | 0 | 1 | 0.0%
   | [shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-route/src/main/java/org/apache/shardingsphere/sharding/route/engine/validator/impl/ShardingUpdateStatementValidator.java](https://coveralls.io/builds/33698016/source?filename=shardingsphere-features%2Fshardingsphere-sharding%2Fshardingsphere-sharding-route%2Fsrc%2Fmain%2Fjava%2Forg%2Fapache%2Fshardingsphere%2Fsharding%2Froute%2Fengine%2Fvalidator%2Fimpl%2FShardingUpdateStatementValidator.java#L75) | 0 | 1 | 0.0%
   | [shardingsphere-sql-parser/shardingsphere-sql-parser-binder/src/main/java/org/apache/shardingsphere/sql/parser/binder/segment/insert/keygen/engine/GeneratedKeyContextEngine.java](https://coveralls.io/builds/33698016/source?filename=shardingsphere-sql-parser%2Fshardingsphere-sql-parser-binder%2Fsrc%2Fmain%2Fjava%2Forg%2Fapache%2Fshardingsphere%2Fsql%2Fparser%2Fbinder%2Fsegment%2Finsert%2Fkeygen%2Fengine%2FGeneratedKeyContextEngine.java#L82) | 11 | 17 | 64.71%
   <!-- | **Total:** | **77** | **88** | **87.5%** | -->
   
   |  Files with Coverage Reduction | New Missed Lines | % |
   | :-----|--------------|--: |
   | [shardingsphere-sql-parser/shardingsphere-sql-parser-statement/src/main/java/org/apache/shardingsphere/sql/parser/sql/dialect/statement/oracle/dml/OracleInsertStatement.java](https://coveralls.io/builds/33698016/source?filename=shardingsphere-sql-parser%2Fshardingsphere-sql-parser-statement%2Fsrc%2Fmain%2Fjava%2Forg%2Fapache%2Fshardingsphere%2Fsql%2Fparser%2Fsql%2Fdialect%2Fstatement%2Foracle%2Fdml%2FOracleInsertStatement.java#L26) | 1 | 0% |
   | [shardingsphere-sql-parser/shardingsphere-sql-parser-statement/src/main/java/org/apache/shardingsphere/sql/parser/sql/dialect/statement/sql92/dml/SQL92InsertStatement.java](https://coveralls.io/builds/33698016/source?filename=shardingsphere-sql-parser%2Fshardingsphere-sql-parser-statement%2Fsrc%2Fmain%2Fjava%2Forg%2Fapache%2Fshardingsphere%2Fsql%2Fparser%2Fsql%2Fdialect%2Fstatement%2Fsql92%2Fdml%2FSQL92InsertStatement.java#L26) | 1 | 0% |
   | [shardingsphere-scaling/shardingsphere-scaling-core/src/main/java/org/apache/shardingsphere/scaling/core/exception/DataCheckFailException.java](https://coveralls.io/builds/33698016/source?filename=shardingsphere-scaling%2Fshardingsphere-scaling-core%2Fsrc%2Fmain%2Fjava%2Forg%2Fapache%2Fshardingsphere%2Fscaling%2Fcore%2Fexception%2FDataCheckFailException.java#L26) | 2 | 0% |
   | [shardingsphere-sql-parser/shardingsphere-sql-parser-statement/src/main/java/org/apache/shardingsphere/sql/parser/sql/common/statement/dml/InsertStatement.java](https://coveralls.io/builds/33698016/source?filename=shardingsphere-sql-parser%2Fshardingsphere-sql-parser-statement%2Fsrc%2Fmain%2Fjava%2Forg%2Fapache%2Fshardingsphere%2Fsql%2Fparser%2Fsql%2Fcommon%2Fstatement%2Fdml%2FInsertStatement.java#L64) | 2 | 40.0% |
   | [shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-rewrite/src/main/java/org/apache/shardingsphere/sharding/rewrite/token/generator/impl/ProjectionsTokenGenerator.java](https://coveralls.io/builds/33698016/source?filename=shardingsphere-features%2Fshardingsphere-sharding%2Fshardingsphere-sharding-rewrite%2Fsrc%2Fmain%2Fjava%2Forg%2Fapache%2Fshardingsphere%2Fsharding%2Frewrite%2Ftoken%2Fgenerator%2Fimpl%2FProjectionsTokenGenerator.java#L88) | 4 | 92.59% |
   | [shardingsphere-scaling/shardingsphere-scaling-bootstrap/src/main/java/org/apache/shardingsphere/scaling/web/HttpServerHandler.java](https://coveralls.io/builds/33698016/source?filename=shardingsphere-scaling%2Fshardingsphere-scaling-bootstrap%2Fsrc%2Fmain%2Fjava%2Forg%2Fapache%2Fshardingsphere%2Fscaling%2Fweb%2FHttpServerHandler.java#L87) | 4 | 86.36% |
   | [shardingsphere-scaling/shardingsphere-scaling-postgresql/src/main/java/org/apache/shardingsphere/scaling/postgresql/PostgreSQLDataConsistencyChecker.java](https://coveralls.io/builds/33698016/source?filename=shardingsphere-scaling%2Fshardingsphere-scaling-postgresql%2Fsrc%2Fmain%2Fjava%2Forg%2Fapache%2Fshardingsphere%2Fscaling%2Fpostgresql%2FPostgreSQLDataConsistencyChecker.java#L34) | 4 | 0% |
   | [shardingsphere-infra/shardingsphere-infra-executor/src/main/java/org/apache/shardingsphere/infra/executor/sql/context/ExecutionContextBuilder.java](https://coveralls.io/builds/33698016/source?filename=shardingsphere-infra%2Fshardingsphere-infra-executor%2Fsrc%2Fmain%2Fjava%2Forg%2Fapache%2Fshardingsphere%2Finfra%2Fexecutor%2Fsql%2Fcontext%2FExecutionContextBuilder.java#L91) | 5 | 85.37% |
   | [shardingsphere-scaling/shardingsphere-scaling-core/src/main/java/org/apache/shardingsphere/scaling/core/check/AbstractDataConsistencyChecker.java](https://coveralls.io/builds/33698016/source?filename=shardingsphere-scaling%2Fshardingsphere-scaling-core%2Fsrc%2Fmain%2Fjava%2Forg%2Fapache%2Fshardingsphere%2Fscaling%2Fcore%2Fcheck%2FAbstractDataConsistencyChecker.java#L69) | 6 | 76.92% |
   | [shardingsphere-scaling/shardingsphere-scaling-core/src/main/java/org/apache/shardingsphere/scaling/core/ScalingJobController.java](https://coveralls.io/builds/33698016/source?filename=shardingsphere-scaling%2Fshardingsphere-scaling-core%2Fsrc%2Fmain%2Fjava%2Forg%2Fapache%2Fshardingsphere%2Fscaling%2Fcore%2FScalingJobController.java#L102) | 7 | 76.47% |
   <!-- | **Total:** | **65** |  | -->
   
   |  Totals | [![Coverage Status](https://coveralls.io/builds/33698016/badge)](https://coveralls.io/builds/33698016) |
   | :-- | --: |
   | Change from base [Build 15013](https://coveralls.io/builds/33680530): |  -0.004% |
   | Covered Lines: | 36625 |
   | Relevant Lines: | 104322 |
   
   ---
   ##### 💛  - [Coveralls](https://coveralls.io)
   


----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [shardingsphere] coveralls commented on pull request #7573: migrate some methods in InsertStatement to InsertStatementContext

Posted by GitBox <gi...@apache.org>.
coveralls commented on pull request #7573:
URL: https://github.com/apache/shardingsphere/pull/7573#issuecomment-697152228


   ## Pull Request Test Coverage Report for [Build 15004](https://coveralls.io/builds/33655132)
   
   * **88** of **96**   **(91.67%)**  changed or added relevant lines in **25** files are covered.
   * No unchanged relevant lines lost coverage.
   * Overall coverage increased (+**0.01%**) to **35.125%**
   
   ---
   
   |  Changes Missing Coverage | Covered Lines | Changed/Added Lines | % |
   | :-----|--------------|--------|---: |
   | [shardingsphere-features/shardingsphere-shadow/shardingsphere-shadow-rewrite/src/main/java/org/apache/shardingsphere/shadow/rewrite/parameter/impl/ShadowInsertValueParameterRewriter.java](https://coveralls.io/builds/33655132/source?filename=shardingsphere-features%2Fshardingsphere-shadow%2Fshardingsphere-shadow-rewrite%2Fsrc%2Fmain%2Fjava%2Forg%2Fapache%2Fshardingsphere%2Fshadow%2Frewrite%2Fparameter%2Fimpl%2FShadowInsertValueParameterRewriter.java#L37) | 0 | 1 | 0.0%
   | [shardingsphere-features/shardingsphere-shadow/shardingsphere-shadow-rewrite/src/main/java/org/apache/shardingsphere/shadow/rewrite/token/generator/impl/ShadowInsertValuesTokenGenerator.java](https://coveralls.io/builds/33655132/source?filename=shardingsphere-features%2Fshardingsphere-shadow%2Fshardingsphere-shadow-rewrite%2Fsrc%2Fmain%2Fjava%2Forg%2Fapache%2Fshardingsphere%2Fshadow%2Frewrite%2Ftoken%2Fgenerator%2Fimpl%2FShadowInsertValuesTokenGenerator.java#L48) | 0 | 1 | 0.0%
   | [shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-route/src/main/java/org/apache/shardingsphere/sharding/route/engine/condition/engine/InsertClauseShardingConditionEngine.java](https://coveralls.io/builds/33655132/source?filename=shardingsphere-features%2Fshardingsphere-sharding%2Fshardingsphere-sharding-route%2Fsrc%2Fmain%2Fjava%2Forg%2Fapache%2Fshardingsphere%2Fsharding%2Froute%2Fengine%2Fcondition%2Fengine%2FInsertClauseShardingConditionEngine.java#L78) | 0 | 1 | 0.0%
   | [shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-route/src/main/java/org/apache/shardingsphere/sharding/route/engine/validator/impl/ShardingDeleteStatementValidator.java](https://coveralls.io/builds/33655132/source?filename=shardingsphere-features%2Fshardingsphere-sharding%2Fshardingsphere-sharding-route%2Fsrc%2Fmain%2Fjava%2Forg%2Fapache%2Fshardingsphere%2Fsharding%2Froute%2Fengine%2Fvalidator%2Fimpl%2FShardingDeleteStatementValidator.java#L46) | 0 | 1 | 0.0%
   | [shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-route/src/main/java/org/apache/shardingsphere/sharding/route/engine/validator/impl/ShardingUpdateStatementValidator.java](https://coveralls.io/builds/33655132/source?filename=shardingsphere-features%2Fshardingsphere-sharding%2Fshardingsphere-sharding-route%2Fsrc%2Fmain%2Fjava%2Forg%2Fapache%2Fshardingsphere%2Fsharding%2Froute%2Fengine%2Fvalidator%2Fimpl%2FShardingUpdateStatementValidator.java#L75) | 0 | 1 | 0.0%
   | [shardingsphere-sql-parser/shardingsphere-sql-parser-statement/src/main/java/org/apache/shardingsphere/sql/parser/sql/dialect/handler/dml/InsertStatementHandler.java](https://coveralls.io/builds/33655132/source?filename=shardingsphere-sql-parser%2Fshardingsphere-sql-parser-statement%2Fsrc%2Fmain%2Fjava%2Forg%2Fapache%2Fshardingsphere%2Fsql%2Fparser%2Fsql%2Fdialect%2Fhandler%2Fdml%2FInsertStatementHandler.java#L60) | 40 | 43 | 93.02%
   <!-- | **Total:** | **88** | **96** | **91.67%** | -->
   
   
   |  Totals | [![Coverage Status](https://coveralls.io/builds/33655132/badge)](https://coveralls.io/builds/33655132) |
   | :-- | --: |
   | Change from base [Build 15003](https://coveralls.io/builds/33654393): |  0.01% |
   | Covered Lines: | 36642 |
   | Relevant Lines: | 104319 |
   
   ---
   ##### 💛  - [Coveralls](https://coveralls.io)
   


----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [shardingsphere] tristaZero merged pull request #7573: migrate some methods in InsertStatement to InsertStatementContext

Posted by GitBox <gi...@apache.org>.
tristaZero merged pull request #7573:
URL: https://github.com/apache/shardingsphere/pull/7573


   


----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [shardingsphere] strongduanmu commented on a change in pull request #7573: migrate some methods in InsertStatement to InsertStatementContext

Posted by GitBox <gi...@apache.org>.
strongduanmu commented on a change in pull request #7573:
URL: https://github.com/apache/shardingsphere/pull/7573#discussion_r493522821



##########
File path: shardingsphere-sql-parser/shardingsphere-sql-parser-statement/src/main/java/org/apache/shardingsphere/sql/parser/sql/dialect/handler/dml/InsertStatementHandler.java
##########
@@ -0,0 +1,165 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.shardingsphere.sql.parser.sql.dialect.handler.dml;
+
+import lombok.AccessLevel;
+import lombok.NoArgsConstructor;
+import org.apache.shardingsphere.sql.parser.sql.common.segment.dml.assignment.AssignmentSegment;
+import org.apache.shardingsphere.sql.parser.sql.common.segment.dml.assignment.InsertValuesSegment;
+import org.apache.shardingsphere.sql.parser.sql.common.segment.dml.assignment.SetAssignmentSegment;
+import org.apache.shardingsphere.sql.parser.sql.common.segment.dml.column.ColumnSegment;
+import org.apache.shardingsphere.sql.parser.sql.common.segment.dml.column.OnDuplicateKeyColumnsSegment;
+import org.apache.shardingsphere.sql.parser.sql.common.segment.dml.expr.ExpressionSegment;
+import org.apache.shardingsphere.sql.parser.sql.common.segment.generic.WithSegment;
+import org.apache.shardingsphere.sql.parser.sql.common.statement.dml.InsertStatement;
+import org.apache.shardingsphere.sql.parser.sql.dialect.statement.mysql.MySQLStatement;
+import org.apache.shardingsphere.sql.parser.sql.dialect.statement.mysql.dml.MySQLInsertStatement;
+import org.apache.shardingsphere.sql.parser.sql.dialect.statement.postgresql.PostgreSQLStatement;
+import org.apache.shardingsphere.sql.parser.sql.dialect.statement.postgresql.dml.PostgreSQLInsertStatement;
+import org.apache.shardingsphere.sql.parser.sql.dialect.statement.sqlserver.SQLServerStatement;
+import org.apache.shardingsphere.sql.parser.sql.dialect.statement.sqlserver.dml.SQLServerInsertStatement;
+
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.Collections;
+import java.util.LinkedList;
+import java.util.List;
+import java.util.Optional;
+
+/**
+ * InsertStatement handler for different dialect SQLStatements.
+ */
+@NoArgsConstructor(access = AccessLevel.PRIVATE)
+public final class InsertStatementHandler {
+
+    /**
+     * Get OnDuplicateKeyColumnsSegment.
+     *
+     * @param insertStatement InsertStatement
+     * @return OnDuplicateKeyColumnsSegment
+     */
+    public static Optional<OnDuplicateKeyColumnsSegment> getOnDuplicateKeyColumnsSegment(final InsertStatement insertStatement) {
+        if (insertStatement instanceof MySQLStatement) {
+            return ((MySQLInsertStatement) insertStatement).getOnDuplicateKeyColumns();
+        }
+        return Optional.empty();
+    }
+
+    /**
+     * Get SetAssignmentSegment.
+     *
+     * @param insertStatement InsertStatement
+     * @return SetAssignmentSegment
+     */
+    public static Optional<SetAssignmentSegment> getSetAssignmentSegment(final InsertStatement insertStatement) {
+        if (insertStatement instanceof MySQLStatement) {
+            return ((MySQLInsertStatement) insertStatement).getSetAssignment();
+        }
+        return Optional.empty();
+    }
+
+    /**
+     * Get WithSegment.
+     *
+     * @param insertStatement InsertStatement
+     * @return WithSegment
+     */
+    public static Optional<WithSegment> getWithSegment(final InsertStatement insertStatement) {
+        if (insertStatement instanceof PostgreSQLStatement) {
+            return ((PostgreSQLInsertStatement) insertStatement).getWithSegment();
+        }
+        if (insertStatement instanceof SQLServerStatement) {
+            return ((SQLServerInsertStatement) insertStatement).getWithSegment();
+        }
+        return Optional.empty();
+    }
+    
+    /**
+     * Get column names.
+     *
+     * @param insertStatement InsertStatement
+     * @return column names collection
+     */
+    public static List<String> getColumnNames(final InsertStatement insertStatement) {
+        Optional<SetAssignmentSegment> setAssignment = getSetAssignmentSegment(insertStatement);
+        return setAssignment.isPresent() ? getColumnNamesForSetAssignment(setAssignment.get()) : getColumnNamesForInsertColumns(insertStatement.getColumns());
+    }
+    
+    private static List<String> getColumnNamesForSetAssignment(final SetAssignmentSegment setAssignment) {
+        List<String> result = new LinkedList<>();
+        for (AssignmentSegment each : setAssignment.getAssignments()) {
+            result.add(each.getColumn().getIdentifier().getValue().toLowerCase());
+        }
+        return result;
+    }
+    
+    private static List<String> getColumnNamesForInsertColumns(final Collection<ColumnSegment> columns) {
+        List<String> result = new LinkedList<>();
+        for (ColumnSegment each : columns) {
+            result.add(each.getIdentifier().getValue().toLowerCase());
+        }
+        return result;
+    }
+    
+    /**
+     * Get value count for per value list.
+     *
+     * @param insertStatement InsertStatement
+     * @return value count
+     */
+    public static int getValueCountForPerGroup(final InsertStatement insertStatement) {

Review comment:
       > Here is my thought about this point,
   > I am a little worried that we mix up the `handler` and `context` for one `SQLStatement`. For me, `handler` is to hide the handling for database dialects and provide the basic functions to get the dialect segments. While, `context` is to give some of the functions containing `ShardingSphere` logics (or simply speaking, for routing and rewriting)
   > I'd like to listen to your thinking. If I missed something, please let me know. :-)
   
   @tristaZero I agree with your point on the responsibilities for `handler` and `context`, and I will optimize the code according to your suggestions.




----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [shardingsphere] strongduanmu commented on pull request #7573: migrate some methods in InsertStatement to InsertStatementContext

Posted by GitBox <gi...@apache.org>.
strongduanmu commented on pull request #7573:
URL: https://github.com/apache/shardingsphere/pull/7573#issuecomment-698706692


   > @strongduanmu
   > 
   > This is an excellent PR! I know you took much time and thought of it, but I supposed it was worth it, which help us improve the logic thinking for programming. Moreover, I believe you definitely have a deeper understanding of the relevant modules of ShardingSphere. So If there are any similar PRs, welcome you to be a reviewer for them!
   > 
   > Best,
   > Trista
   
   @tristaZero Thank you very much for your perfect suggestion in this PR, which greatly improved my programming thinking. I am very willing to review related changes later. 😀


----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [shardingsphere] strongduanmu commented on pull request #7573: migrate some methods in InsertStatement to InsertStatementContext

Posted by GitBox <gi...@apache.org>.
strongduanmu commented on pull request #7573:
URL: https://github.com/apache/shardingsphere/pull/7573#issuecomment-698706692


   > @strongduanmu
   > 
   > This is an excellent PR! I know you took much time and thought of it, but I supposed it was worth it, which help us improve the logic thinking for programming. Moreover, I believe you definitely have a deeper understanding of the relevant modules of ShardingSphere. So If there are any similar PRs, welcome you to be a reviewer for them!
   > 
   > Best,
   > Trista
   
   @tristaZero Thank you very much for your perfect suggestion in this PR, which greatly improved my programming thinking. I am very willing to review related changes later. 😀


----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [shardingsphere] strongduanmu commented on a change in pull request #7573: migrate some methods in InsertStatement to InsertStatementContext

Posted by GitBox <gi...@apache.org>.
strongduanmu commented on a change in pull request #7573:
URL: https://github.com/apache/shardingsphere/pull/7573#discussion_r493497714



##########
File path: shardingsphere-sql-parser/shardingsphere-sql-parser-statement/src/main/java/org/apache/shardingsphere/sql/parser/sql/dialect/handler/dml/InsertStatementHandler.java
##########
@@ -0,0 +1,165 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.shardingsphere.sql.parser.sql.dialect.handler.dml;
+
+import lombok.AccessLevel;
+import lombok.NoArgsConstructor;
+import org.apache.shardingsphere.sql.parser.sql.common.segment.dml.assignment.AssignmentSegment;
+import org.apache.shardingsphere.sql.parser.sql.common.segment.dml.assignment.InsertValuesSegment;
+import org.apache.shardingsphere.sql.parser.sql.common.segment.dml.assignment.SetAssignmentSegment;
+import org.apache.shardingsphere.sql.parser.sql.common.segment.dml.column.ColumnSegment;
+import org.apache.shardingsphere.sql.parser.sql.common.segment.dml.column.OnDuplicateKeyColumnsSegment;
+import org.apache.shardingsphere.sql.parser.sql.common.segment.dml.expr.ExpressionSegment;
+import org.apache.shardingsphere.sql.parser.sql.common.segment.generic.WithSegment;
+import org.apache.shardingsphere.sql.parser.sql.common.statement.dml.InsertStatement;
+import org.apache.shardingsphere.sql.parser.sql.dialect.statement.mysql.MySQLStatement;
+import org.apache.shardingsphere.sql.parser.sql.dialect.statement.mysql.dml.MySQLInsertStatement;
+import org.apache.shardingsphere.sql.parser.sql.dialect.statement.postgresql.PostgreSQLStatement;
+import org.apache.shardingsphere.sql.parser.sql.dialect.statement.postgresql.dml.PostgreSQLInsertStatement;
+import org.apache.shardingsphere.sql.parser.sql.dialect.statement.sqlserver.SQLServerStatement;
+import org.apache.shardingsphere.sql.parser.sql.dialect.statement.sqlserver.dml.SQLServerInsertStatement;
+
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.Collections;
+import java.util.LinkedList;
+import java.util.List;
+import java.util.Optional;
+
+/**
+ * InsertStatement handler for different dialect SQLStatements.
+ */
+@NoArgsConstructor(access = AccessLevel.PRIVATE)
+public final class InsertStatementHandler {
+
+    /**
+     * Get OnDuplicateKeyColumnsSegment.
+     *
+     * @param insertStatement InsertStatement
+     * @return OnDuplicateKeyColumnsSegment
+     */
+    public static Optional<OnDuplicateKeyColumnsSegment> getOnDuplicateKeyColumnsSegment(final InsertStatement insertStatement) {
+        if (insertStatement instanceof MySQLStatement) {
+            return ((MySQLInsertStatement) insertStatement).getOnDuplicateKeyColumns();
+        }
+        return Optional.empty();
+    }
+
+    /**
+     * Get SetAssignmentSegment.
+     *
+     * @param insertStatement InsertStatement
+     * @return SetAssignmentSegment
+     */
+    public static Optional<SetAssignmentSegment> getSetAssignmentSegment(final InsertStatement insertStatement) {
+        if (insertStatement instanceof MySQLStatement) {
+            return ((MySQLInsertStatement) insertStatement).getSetAssignment();
+        }
+        return Optional.empty();
+    }
+
+    /**
+     * Get WithSegment.
+     *
+     * @param insertStatement InsertStatement
+     * @return WithSegment
+     */
+    public static Optional<WithSegment> getWithSegment(final InsertStatement insertStatement) {
+        if (insertStatement instanceof PostgreSQLStatement) {
+            return ((PostgreSQLInsertStatement) insertStatement).getWithSegment();
+        }
+        if (insertStatement instanceof SQLServerStatement) {
+            return ((SQLServerInsertStatement) insertStatement).getWithSegment();
+        }
+        return Optional.empty();
+    }
+    
+    /**
+     * Get column names.
+     *
+     * @param insertStatement InsertStatement
+     * @return column names collection
+     */
+    public static List<String> getColumnNames(final InsertStatement insertStatement) {

Review comment:
       > How about moving `getColumnNames` and `getAllValueExpressions` to `InsertStatementContext.java`?
   > Accordingly, please consider the following code clip as well.
   > 
   > ```java
   > generatedKeyContext = new GeneratedKeyContextEngine(schemaMetaData).createGenerateKeyContext(parameters, sqlStatement).orElse(null);
   > 
   > -->
   > 
   > generatedKeyContext = new GeneratedKeyContextEngine(sqlStatement, schemaMetaData).createGenerateKeyContext(columnNames, valueExpressions, parameters).orElse(null);
   > ```
   
   @tristaZero I like this way of implementation and I will try to optimize it. 👍




----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [shardingsphere] strongduanmu commented on a change in pull request #7573: migrate some methods in InsertStatement to InsertStatementContext

Posted by GitBox <gi...@apache.org>.
strongduanmu commented on a change in pull request #7573:
URL: https://github.com/apache/shardingsphere/pull/7573#discussion_r493449893



##########
File path: shardingsphere-sql-parser/shardingsphere-sql-parser-statement/src/main/java/org/apache/shardingsphere/sql/parser/sql/dialect/handler/dml/InsertStatementHandler.java
##########
@@ -0,0 +1,165 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.shardingsphere.sql.parser.sql.dialect.handler.dml;
+
+import lombok.AccessLevel;
+import lombok.NoArgsConstructor;
+import org.apache.shardingsphere.sql.parser.sql.common.segment.dml.assignment.AssignmentSegment;
+import org.apache.shardingsphere.sql.parser.sql.common.segment.dml.assignment.InsertValuesSegment;
+import org.apache.shardingsphere.sql.parser.sql.common.segment.dml.assignment.SetAssignmentSegment;
+import org.apache.shardingsphere.sql.parser.sql.common.segment.dml.column.ColumnSegment;
+import org.apache.shardingsphere.sql.parser.sql.common.segment.dml.column.OnDuplicateKeyColumnsSegment;
+import org.apache.shardingsphere.sql.parser.sql.common.segment.dml.expr.ExpressionSegment;
+import org.apache.shardingsphere.sql.parser.sql.common.segment.generic.WithSegment;
+import org.apache.shardingsphere.sql.parser.sql.common.statement.dml.InsertStatement;
+import org.apache.shardingsphere.sql.parser.sql.dialect.statement.mysql.MySQLStatement;
+import org.apache.shardingsphere.sql.parser.sql.dialect.statement.mysql.dml.MySQLInsertStatement;
+import org.apache.shardingsphere.sql.parser.sql.dialect.statement.postgresql.PostgreSQLStatement;
+import org.apache.shardingsphere.sql.parser.sql.dialect.statement.postgresql.dml.PostgreSQLInsertStatement;
+import org.apache.shardingsphere.sql.parser.sql.dialect.statement.sqlserver.SQLServerStatement;
+import org.apache.shardingsphere.sql.parser.sql.dialect.statement.sqlserver.dml.SQLServerInsertStatement;
+
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.Collections;
+import java.util.LinkedList;
+import java.util.List;
+import java.util.Optional;
+
+/**
+ * InsertStatement handler for different dialect SQLStatements.
+ */
+@NoArgsConstructor(access = AccessLevel.PRIVATE)
+public final class InsertStatementHandler {
+
+    /**
+     * Get OnDuplicateKeyColumnsSegment.
+     *
+     * @param insertStatement InsertStatement
+     * @return OnDuplicateKeyColumnsSegment
+     */
+    public static Optional<OnDuplicateKeyColumnsSegment> getOnDuplicateKeyColumnsSegment(final InsertStatement insertStatement) {
+        if (insertStatement instanceof MySQLStatement) {
+            return ((MySQLInsertStatement) insertStatement).getOnDuplicateKeyColumns();
+        }
+        return Optional.empty();
+    }
+
+    /**
+     * Get SetAssignmentSegment.
+     *
+     * @param insertStatement InsertStatement
+     * @return SetAssignmentSegment
+     */
+    public static Optional<SetAssignmentSegment> getSetAssignmentSegment(final InsertStatement insertStatement) {
+        if (insertStatement instanceof MySQLStatement) {
+            return ((MySQLInsertStatement) insertStatement).getSetAssignment();
+        }
+        return Optional.empty();
+    }
+
+    /**
+     * Get WithSegment.
+     *
+     * @param insertStatement InsertStatement
+     * @return WithSegment
+     */
+    public static Optional<WithSegment> getWithSegment(final InsertStatement insertStatement) {
+        if (insertStatement instanceof PostgreSQLStatement) {
+            return ((PostgreSQLInsertStatement) insertStatement).getWithSegment();
+        }
+        if (insertStatement instanceof SQLServerStatement) {
+            return ((SQLServerInsertStatement) insertStatement).getWithSegment();
+        }
+        return Optional.empty();
+    }
+    
+    /**
+     * Get column names.
+     *
+     * @param insertStatement InsertStatement
+     * @return column names collection
+     */
+    public static List<String> getColumnNames(final InsertStatement insertStatement) {
+        Optional<SetAssignmentSegment> setAssignment = getSetAssignmentSegment(insertStatement);
+        return setAssignment.isPresent() ? getColumnNamesForSetAssignment(setAssignment.get()) : getColumnNamesForInsertColumns(insertStatement.getColumns());
+    }
+    
+    private static List<String> getColumnNamesForSetAssignment(final SetAssignmentSegment setAssignment) {
+        List<String> result = new LinkedList<>();
+        for (AssignmentSegment each : setAssignment.getAssignments()) {
+            result.add(each.getColumn().getIdentifier().getValue().toLowerCase());
+        }
+        return result;
+    }
+    
+    private static List<String> getColumnNamesForInsertColumns(final Collection<ColumnSegment> columns) {
+        List<String> result = new LinkedList<>();
+        for (ColumnSegment each : columns) {
+            result.add(each.getIdentifier().getValue().toLowerCase());
+        }
+        return result;
+    }
+    
+    /**
+     * Get value count for per value list.
+     *
+     * @param insertStatement InsertStatement
+     * @return value count
+     */
+    public static int getValueCountForPerGroup(final InsertStatement insertStatement) {

Review comment:
       > Since `getValueCountForPerGroup` is only used by `GeneratedKeyContextEngine`, do you think it is better to move it to `GeneratedKeyContextEngine`?
   
   @tristaZero Yes, I agree with you, there is really no other scenario using this method.
   




----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [shardingsphere] tristaZero merged pull request #7573: migrate some methods in InsertStatement to InsertStatementContext

Posted by GitBox <gi...@apache.org>.
tristaZero merged pull request #7573:
URL: https://github.com/apache/shardingsphere/pull/7573


   


----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [shardingsphere] tristaZero commented on a change in pull request #7573: migrate some methods in InsertStatement to InsertStatementContext

Posted by GitBox <gi...@apache.org>.
tristaZero commented on a change in pull request #7573:
URL: https://github.com/apache/shardingsphere/pull/7573#discussion_r493262289



##########
File path: shardingsphere-sql-parser/shardingsphere-sql-parser-statement/src/main/java/org/apache/shardingsphere/sql/parser/sql/dialect/handler/dml/InsertStatementHandler.java
##########
@@ -0,0 +1,165 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.shardingsphere.sql.parser.sql.dialect.handler.dml;
+
+import lombok.AccessLevel;
+import lombok.NoArgsConstructor;
+import org.apache.shardingsphere.sql.parser.sql.common.segment.dml.assignment.AssignmentSegment;
+import org.apache.shardingsphere.sql.parser.sql.common.segment.dml.assignment.InsertValuesSegment;
+import org.apache.shardingsphere.sql.parser.sql.common.segment.dml.assignment.SetAssignmentSegment;
+import org.apache.shardingsphere.sql.parser.sql.common.segment.dml.column.ColumnSegment;
+import org.apache.shardingsphere.sql.parser.sql.common.segment.dml.column.OnDuplicateKeyColumnsSegment;
+import org.apache.shardingsphere.sql.parser.sql.common.segment.dml.expr.ExpressionSegment;
+import org.apache.shardingsphere.sql.parser.sql.common.segment.generic.WithSegment;
+import org.apache.shardingsphere.sql.parser.sql.common.statement.dml.InsertStatement;
+import org.apache.shardingsphere.sql.parser.sql.dialect.statement.mysql.MySQLStatement;
+import org.apache.shardingsphere.sql.parser.sql.dialect.statement.mysql.dml.MySQLInsertStatement;
+import org.apache.shardingsphere.sql.parser.sql.dialect.statement.postgresql.PostgreSQLStatement;
+import org.apache.shardingsphere.sql.parser.sql.dialect.statement.postgresql.dml.PostgreSQLInsertStatement;
+import org.apache.shardingsphere.sql.parser.sql.dialect.statement.sqlserver.SQLServerStatement;
+import org.apache.shardingsphere.sql.parser.sql.dialect.statement.sqlserver.dml.SQLServerInsertStatement;
+
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.Collections;
+import java.util.LinkedList;
+import java.util.List;
+import java.util.Optional;
+
+/**
+ * InsertStatement handler for different dialect SQLStatements.
+ */
+@NoArgsConstructor(access = AccessLevel.PRIVATE)
+public final class InsertStatementHandler {
+
+    /**
+     * Get OnDuplicateKeyColumnsSegment.
+     *
+     * @param insertStatement InsertStatement
+     * @return OnDuplicateKeyColumnsSegment
+     */
+    public static Optional<OnDuplicateKeyColumnsSegment> getOnDuplicateKeyColumnsSegment(final InsertStatement insertStatement) {
+        if (insertStatement instanceof MySQLStatement) {
+            return ((MySQLInsertStatement) insertStatement).getOnDuplicateKeyColumns();
+        }
+        return Optional.empty();
+    }
+
+    /**
+     * Get SetAssignmentSegment.
+     *
+     * @param insertStatement InsertStatement
+     * @return SetAssignmentSegment
+     */
+    public static Optional<SetAssignmentSegment> getSetAssignmentSegment(final InsertStatement insertStatement) {
+        if (insertStatement instanceof MySQLStatement) {
+            return ((MySQLInsertStatement) insertStatement).getSetAssignment();
+        }
+        return Optional.empty();
+    }
+
+    /**
+     * Get WithSegment.
+     *
+     * @param insertStatement InsertStatement
+     * @return WithSegment
+     */
+    public static Optional<WithSegment> getWithSegment(final InsertStatement insertStatement) {
+        if (insertStatement instanceof PostgreSQLStatement) {
+            return ((PostgreSQLInsertStatement) insertStatement).getWithSegment();
+        }
+        if (insertStatement instanceof SQLServerStatement) {
+            return ((SQLServerInsertStatement) insertStatement).getWithSegment();
+        }
+        return Optional.empty();
+    }
+    
+    /**
+     * Get column names.
+     *
+     * @param insertStatement InsertStatement
+     * @return column names collection
+     */
+    public static List<String> getColumnNames(final InsertStatement insertStatement) {
+        Optional<SetAssignmentSegment> setAssignment = getSetAssignmentSegment(insertStatement);
+        return setAssignment.isPresent() ? getColumnNamesForSetAssignment(setAssignment.get()) : getColumnNamesForInsertColumns(insertStatement.getColumns());
+    }
+    
+    private static List<String> getColumnNamesForSetAssignment(final SetAssignmentSegment setAssignment) {
+        List<String> result = new LinkedList<>();
+        for (AssignmentSegment each : setAssignment.getAssignments()) {
+            result.add(each.getColumn().getIdentifier().getValue().toLowerCase());
+        }
+        return result;
+    }
+    
+    private static List<String> getColumnNamesForInsertColumns(final Collection<ColumnSegment> columns) {
+        List<String> result = new LinkedList<>();
+        for (ColumnSegment each : columns) {
+            result.add(each.getIdentifier().getValue().toLowerCase());
+        }
+        return result;
+    }
+    
+    /**
+     * Get value count for per value list.
+     *
+     * @param insertStatement InsertStatement
+     * @return value count
+     */
+    public static int getValueCountForPerGroup(final InsertStatement insertStatement) {

Review comment:
       Since `getValueCountForPerGroup` is only used by `GeneratedKeyContextEngine`, do you think it is better to move it to `GeneratedKeyContextEngine`?

##########
File path: shardingsphere-sql-parser/shardingsphere-sql-parser-statement/src/main/java/org/apache/shardingsphere/sql/parser/sql/dialect/handler/dml/InsertStatementHandler.java
##########
@@ -0,0 +1,165 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.shardingsphere.sql.parser.sql.dialect.handler.dml;
+
+import lombok.AccessLevel;
+import lombok.NoArgsConstructor;
+import org.apache.shardingsphere.sql.parser.sql.common.segment.dml.assignment.AssignmentSegment;
+import org.apache.shardingsphere.sql.parser.sql.common.segment.dml.assignment.InsertValuesSegment;
+import org.apache.shardingsphere.sql.parser.sql.common.segment.dml.assignment.SetAssignmentSegment;
+import org.apache.shardingsphere.sql.parser.sql.common.segment.dml.column.ColumnSegment;
+import org.apache.shardingsphere.sql.parser.sql.common.segment.dml.column.OnDuplicateKeyColumnsSegment;
+import org.apache.shardingsphere.sql.parser.sql.common.segment.dml.expr.ExpressionSegment;
+import org.apache.shardingsphere.sql.parser.sql.common.segment.generic.WithSegment;
+import org.apache.shardingsphere.sql.parser.sql.common.statement.dml.InsertStatement;
+import org.apache.shardingsphere.sql.parser.sql.dialect.statement.mysql.MySQLStatement;
+import org.apache.shardingsphere.sql.parser.sql.dialect.statement.mysql.dml.MySQLInsertStatement;
+import org.apache.shardingsphere.sql.parser.sql.dialect.statement.postgresql.PostgreSQLStatement;
+import org.apache.shardingsphere.sql.parser.sql.dialect.statement.postgresql.dml.PostgreSQLInsertStatement;
+import org.apache.shardingsphere.sql.parser.sql.dialect.statement.sqlserver.SQLServerStatement;
+import org.apache.shardingsphere.sql.parser.sql.dialect.statement.sqlserver.dml.SQLServerInsertStatement;
+
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.Collections;
+import java.util.LinkedList;
+import java.util.List;
+import java.util.Optional;
+
+/**
+ * InsertStatement handler for different dialect SQLStatements.
+ */
+@NoArgsConstructor(access = AccessLevel.PRIVATE)
+public final class InsertStatementHandler {
+
+    /**
+     * Get OnDuplicateKeyColumnsSegment.
+     *
+     * @param insertStatement InsertStatement
+     * @return OnDuplicateKeyColumnsSegment
+     */
+    public static Optional<OnDuplicateKeyColumnsSegment> getOnDuplicateKeyColumnsSegment(final InsertStatement insertStatement) {
+        if (insertStatement instanceof MySQLStatement) {
+            return ((MySQLInsertStatement) insertStatement).getOnDuplicateKeyColumns();
+        }
+        return Optional.empty();
+    }
+
+    /**
+     * Get SetAssignmentSegment.
+     *
+     * @param insertStatement InsertStatement
+     * @return SetAssignmentSegment
+     */
+    public static Optional<SetAssignmentSegment> getSetAssignmentSegment(final InsertStatement insertStatement) {
+        if (insertStatement instanceof MySQLStatement) {
+            return ((MySQLInsertStatement) insertStatement).getSetAssignment();
+        }
+        return Optional.empty();
+    }
+
+    /**
+     * Get WithSegment.
+     *
+     * @param insertStatement InsertStatement
+     * @return WithSegment
+     */
+    public static Optional<WithSegment> getWithSegment(final InsertStatement insertStatement) {
+        if (insertStatement instanceof PostgreSQLStatement) {
+            return ((PostgreSQLInsertStatement) insertStatement).getWithSegment();
+        }
+        if (insertStatement instanceof SQLServerStatement) {
+            return ((SQLServerInsertStatement) insertStatement).getWithSegment();
+        }
+        return Optional.empty();
+    }
+    
+    /**
+     * Get column names.
+     *
+     * @param insertStatement InsertStatement
+     * @return column names collection
+     */
+    public static List<String> getColumnNames(final InsertStatement insertStatement) {

Review comment:
       How about moving `getColumnNames` and `getAllValueExpressions` to `InsertStatementContext.java`?
   Accordingly, please consider the following code clip as well.
   ```java
   generatedKeyContext = new GeneratedKeyContextEngine(schemaMetaData).createGenerateKeyContext(parameters, sqlStatement).orElse(null);
   
   -->
   
   generatedKeyContext = new GeneratedKeyContextEngine(sqlStatement, schemaMetaData).createGenerateKeyContext(columnNames, valueExpressions, parameters).orElse(null);
   ```

##########
File path: shardingsphere-sql-parser/shardingsphere-sql-parser-statement/src/main/java/org/apache/shardingsphere/sql/parser/sql/dialect/handler/dml/InsertStatementHandler.java
##########
@@ -0,0 +1,165 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.shardingsphere.sql.parser.sql.dialect.handler.dml;
+
+import lombok.AccessLevel;
+import lombok.NoArgsConstructor;
+import org.apache.shardingsphere.sql.parser.sql.common.segment.dml.assignment.AssignmentSegment;
+import org.apache.shardingsphere.sql.parser.sql.common.segment.dml.assignment.InsertValuesSegment;
+import org.apache.shardingsphere.sql.parser.sql.common.segment.dml.assignment.SetAssignmentSegment;
+import org.apache.shardingsphere.sql.parser.sql.common.segment.dml.column.ColumnSegment;
+import org.apache.shardingsphere.sql.parser.sql.common.segment.dml.column.OnDuplicateKeyColumnsSegment;
+import org.apache.shardingsphere.sql.parser.sql.common.segment.dml.expr.ExpressionSegment;
+import org.apache.shardingsphere.sql.parser.sql.common.segment.generic.WithSegment;
+import org.apache.shardingsphere.sql.parser.sql.common.statement.dml.InsertStatement;
+import org.apache.shardingsphere.sql.parser.sql.dialect.statement.mysql.MySQLStatement;
+import org.apache.shardingsphere.sql.parser.sql.dialect.statement.mysql.dml.MySQLInsertStatement;
+import org.apache.shardingsphere.sql.parser.sql.dialect.statement.postgresql.PostgreSQLStatement;
+import org.apache.shardingsphere.sql.parser.sql.dialect.statement.postgresql.dml.PostgreSQLInsertStatement;
+import org.apache.shardingsphere.sql.parser.sql.dialect.statement.sqlserver.SQLServerStatement;
+import org.apache.shardingsphere.sql.parser.sql.dialect.statement.sqlserver.dml.SQLServerInsertStatement;
+
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.Collections;
+import java.util.LinkedList;
+import java.util.List;
+import java.util.Optional;
+
+/**
+ * InsertStatement handler for different dialect SQLStatements.
+ */
+@NoArgsConstructor(access = AccessLevel.PRIVATE)
+public final class InsertStatementHandler {
+
+    /**
+     * Get OnDuplicateKeyColumnsSegment.
+     *
+     * @param insertStatement InsertStatement
+     * @return OnDuplicateKeyColumnsSegment
+     */
+    public static Optional<OnDuplicateKeyColumnsSegment> getOnDuplicateKeyColumnsSegment(final InsertStatement insertStatement) {
+        if (insertStatement instanceof MySQLStatement) {
+            return ((MySQLInsertStatement) insertStatement).getOnDuplicateKeyColumns();
+        }
+        return Optional.empty();
+    }
+
+    /**
+     * Get SetAssignmentSegment.
+     *
+     * @param insertStatement InsertStatement
+     * @return SetAssignmentSegment
+     */
+    public static Optional<SetAssignmentSegment> getSetAssignmentSegment(final InsertStatement insertStatement) {
+        if (insertStatement instanceof MySQLStatement) {
+            return ((MySQLInsertStatement) insertStatement).getSetAssignment();
+        }
+        return Optional.empty();
+    }
+
+    /**
+     * Get WithSegment.
+     *
+     * @param insertStatement InsertStatement
+     * @return WithSegment
+     */
+    public static Optional<WithSegment> getWithSegment(final InsertStatement insertStatement) {
+        if (insertStatement instanceof PostgreSQLStatement) {
+            return ((PostgreSQLInsertStatement) insertStatement).getWithSegment();
+        }
+        if (insertStatement instanceof SQLServerStatement) {
+            return ((SQLServerInsertStatement) insertStatement).getWithSegment();
+        }
+        return Optional.empty();
+    }
+    
+    /**
+     * Get column names.
+     *
+     * @param insertStatement InsertStatement
+     * @return column names collection
+     */
+    public static List<String> getColumnNames(final InsertStatement insertStatement) {
+        Optional<SetAssignmentSegment> setAssignment = getSetAssignmentSegment(insertStatement);
+        return setAssignment.isPresent() ? getColumnNamesForSetAssignment(setAssignment.get()) : getColumnNamesForInsertColumns(insertStatement.getColumns());
+    }
+    
+    private static List<String> getColumnNamesForSetAssignment(final SetAssignmentSegment setAssignment) {
+        List<String> result = new LinkedList<>();
+        for (AssignmentSegment each : setAssignment.getAssignments()) {
+            result.add(each.getColumn().getIdentifier().getValue().toLowerCase());
+        }
+        return result;
+    }
+    
+    private static List<String> getColumnNamesForInsertColumns(final Collection<ColumnSegment> columns) {
+        List<String> result = new LinkedList<>();
+        for (ColumnSegment each : columns) {
+            result.add(each.getIdentifier().getValue().toLowerCase());
+        }
+        return result;
+    }
+    
+    /**
+     * Get value count for per value list.
+     *
+     * @param insertStatement InsertStatement
+     * @return value count
+     */
+    public static int getValueCountForPerGroup(final InsertStatement insertStatement) {

Review comment:
       Here is my thought about this point,
   I am a little worried that we mix up the `handler` and `context` for one `SQLStatement`. For me, `handler` is to hide the handling for database dialects and provide the basic functions to get the dialect segments. While, `context` is to give some of the functions containing `ShardingSphere` logics (or simply speaking, for routing and rewriting)
   I'd like to listen to your thinking. If I missed something, please let me know. :-)




----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org