You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@shardingsphere.apache.org by "strongduanmu (via GitHub)" <gi...@apache.org> on 2023/09/15 04:56:33 UTC

[GitHub] [shardingsphere] strongduanmu commented on a diff in pull request #27904: fix issue-27424 when the table contains case-sensitive fields

strongduanmu commented on code in PR #27904:
URL: https://github.com/apache/shardingsphere/pull/27904#discussion_r1326789282


##########
features/sharding/core/src/main/java/org/apache/shardingsphere/sharding/route/engine/condition/engine/InsertClauseShardingConditionEngine.java:
##########
@@ -100,7 +100,7 @@ private void appendMissingShardingConditions(final InsertStatementContext sqlSta
             return;
         }
         for (String each : allColumnNames) {
-            if (!columnNames.contains(each) && !shardingRule.isGenerateKeyColumn(each, tableName) && shardingRule.findShardingColumn(each, tableName).isPresent()) {
+            if (!columnNames.contains(each.toLowerCase()) && !shardingRule.isGenerateKeyColumn(each, tableName) && shardingRule.findShardingColumn(each, tableName).isPresent()) {

Review Comment:
   Why convert each to lowerCase?



##########
infra/binder/src/main/java/org/apache/shardingsphere/infra/binder/context/statement/dml/InsertStatementContext.java:
##########
@@ -93,7 +93,7 @@ public InsertStatementContext(final ShardingSphereMetaData metaData, final List<
         onDuplicateKeyUpdateValueContext = getOnDuplicateKeyUpdateValueContext(params, parametersOffset).orElse(null);
         tablesContext = new TablesContext(getAllSimpleTableSegments(), getDatabaseType());
         ShardingSphereSchema schema = getSchema(metaData, defaultDatabaseName);
-        columnNames = containsInsertColumns() ? insertColumnNames : schema.getVisibleColumnNames(sqlStatement.getTable().getTableName().getIdentifier().getValue());
+        columnNames = containsInsertColumns() ? insertColumnNames : schema.getVisibleColumnNames(sqlStatement.getTable().getTableName().getIdentifier().getValue().toLowerCase());

Review Comment:
   The result of getVisibleColumnNames may be orginal column in DBMS.



-- 
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.

To unsubscribe, e-mail: notifications-unsubscribe@shardingsphere.apache.org

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