<h2 dir="auto">Bug Report</h2>
<p dir="auto"><strong>For English only</strong>, other languages will not accept.</p>
<p dir="auto">Before report a bug, make sure you have:</p>
<ul dir="auto">
<li>Searched open and closed <a href="https://github.com/apache/incubator-shardingsphere/issues">GitHub issues</a>.</li>
<li>Read documentation: <a href="https://shardingsphere.apache.org/document/current/en/overview" rel="nofollow">ShardingSphere Doc</a>.</li>
</ul>
<p dir="auto">Please pay attention on issues you submitted, because we maybe need more details.<br>
If no response <strong>more than 7 days</strong> and we cannot reproduce it on current information, we will <strong>close it</strong>.</p>
<p dir="auto">Please answer these questions before submitting your issue. Thanks!</p>
<h3 dir="auto">Which version of ShardingSphere did you use?</h3>
<p dir="auto"><code class="notranslate">4.0.0-RC2</code></p>
<h3 dir="auto">Which project did you use? Sharding-JDBC or Sharding-Proxy?</h3>
<p dir="auto"><code class="notranslate">Sharding-JDBC</code></p>
<h3 dir="auto">Expected behavior</h3>
<p dir="auto"><code class="notranslate">INSERT INTO table_a (id,col_1,col_2) VALUES(1,#{bean.val1}, #{bean.val2}) ON DUPLICATE KEY UPDATE col_2 = col_2 + #{bean.val2}</code>  should execute successfully.</p>
<h3 dir="auto">Actual behavior</h3>
<p dir="auto">got exception</p>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="org.springframework.jdbc.BadSqlGrammarException: 
### Error updating database.  Cause: java.sql.SQLException: No value specified for parameter 3
### The error may involve com.duoku.vipintegral.dao.vipscore.UserScoreLevelMapper.insertOrUpdate-Inline
### The error occurred while setting parameters
### SQL: INSERT INTO test_a (id,col_1,col_2) VALUES(1,?, ?) ON DUPLICATE KEY UPDATE col_2 = col_2 + ?
### Cause: java.sql.SQLException: No value specified for parameter 3
; bad SQL grammar []; nested exception is java.sql.SQLException: No value specified for parameter 3"><pre class="notranslate"><code class="notranslate">org.springframework.jdbc.BadSqlGrammarException: 
### Error updating database.  Cause: java.sql.SQLException: No value specified for parameter 3
### The error may involve com.duoku.vipintegral.dao.vipscore.UserScoreLevelMapper.insertOrUpdate-Inline
### The error occurred while setting parameters
### SQL: INSERT INTO test_a (id,col_1,col_2) VALUES(1,?, ?) ON DUPLICATE KEY UPDATE col_2 = col_2 + ?
### Cause: java.sql.SQLException: No value specified for parameter 3
; bad SQL grammar []; nested exception is java.sql.SQLException: No value specified for parameter 3
</code></pre></div>
<h3 dir="auto">Reason analyze (If you can)</h3>
<p dir="auto">Debug from the source,found that the num of parameters just only get from <code class="notranslate">InsertValuesSegment</code>, but the parameter after <code class="notranslate">ON DUPLICATE KEY UPDATE</code> is not included in the calculation.And I also can not find values that belong to 'OnDuplicateKey' expression  in <code class="notranslate">OnDuplicateKeyColumnsSegment</code>.</p>
<p dir="auto"><a href="https://github.com/apache/incubator-shardingsphere/blob/85f2ff877a7aaf122998964a0d03f7c9b2830e36/sharding-core/sharding-core-optimize/src/main/java/org/apache/shardingsphere/core/optimize/sharding/engnie/dml/ShardingInsertOptimizeEngine.java#L70">https://github.com/apache/incubator-shardingsphere/blob/85f2ff877a7aaf122998964a0d03f7c9b2830e36/sharding-core/sharding-core-optimize/src/main/java/org/apache/shardingsphere/core/optimize/sharding/engnie/dml/ShardingInsertOptimizeEngine.java#L70</a></p>
<p dir="auto"><code class="notranslate">currentParameters</code> do not contains the parameter for 'ON DUPLICATE KEY UPDATE',and <code class="notranslate">parameters</code> is full.</p>
<h3 dir="auto">Steps to reproduce the behavior, such as: SQL to execute, sharding rule configuration, when exception occur etc.</h3>
<ul dir="auto">
<li>sql</li>
</ul>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="CREATE TABLE `user` (
  `id` int(10) unsigned NOT NULL COMMENT '主键',
  `col_1` varchar(20) NOT NULL DEFAULT '' COMMENT 'val_1',
  `col_2` int(10) NOT NULL DEFAULT '0' COMMENT 'val_int_2',
  PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;

INSERT INTO table_a (id,col_1,col_2) VALUES(1,#{bean.val1}, #{bean.val2}) ON DUPLICATE KEY UPDATE col_2 = col_2 + #{bean.val2}"><pre class="notranslate"><code class="notranslate">CREATE TABLE `user` (
  `id` int(10) unsigned NOT NULL COMMENT '主键',
  `col_1` varchar(20) NOT NULL DEFAULT '' COMMENT 'val_1',
  `col_2` int(10) NOT NULL DEFAULT '0' COMMENT 'val_int_2',
  PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;

INSERT INTO table_a (id,col_1,col_2) VALUES(1,#{bean.val1}, #{bean.val2}) ON DUPLICATE KEY UPDATE col_2 = col_2 + #{bean.val2}
</code></pre></div>
<ul dir="auto">
<li>in mybatis3</li>
<li>any shareding rule.</li>
</ul>
<h3 dir="auto">Example codes for reproduce this issue (such as a github link).</h3>
<h2 dir="auto">Feature Request</h2>
<p dir="auto"><strong>For English only</strong>, other languages will not accept.</p>
<p dir="auto">Please pay attention on issues you submitted, because we maybe need more details.<br>
If no response <strong>more than 7 days</strong> and we cannot make decision by current information, we will <strong>close it</strong>.</p>
<p dir="auto">Please answer these questions before submitting your issue. Thanks!</p>
<h3 dir="auto">Is your feature request related to a problem?</h3>
<p dir="auto">No.</p>
<h3 dir="auto">Describe the feature you would like.</h3>
<p dir="auto">hope the sharding.jdbc.datasource.names in application.properties can support expression like ds,ds_${0..3}。<br>
but， the SpringBootConfiguration show me that only support datasource names separated by comma. if tens of names， the conf is unfriendly at all.</p>