- 在RouterUtil类中,public static boolean processInsert方法里改成如下:
-
// 如果主键不在插入语句的fields中,则需要进一步处理 TableConfig tableConfig = schema.getTables().get(tableName); if (!tableConfig.isAutoIncrement()) { boolean processedInsert = !isPKInFields(origSQL, primaryKey, firstLeftBracketIndex, firstRightBracketIndex); if (processedInsert) { List<String> insertSQLs = handleBatchInsert(origSQL, valuesIndex); for (String insertSQL : insertSQLs) { processInsert(sc, schema, sqlType, insertSQL, tableName, primaryKey, firstLeftBracketIndex + 1, insertSQL.indexOf(‘(‘, firstRightBracketIndex) + 1); }} return processedInsert; } else { return false; }
时间: 2024-10-05 17:37:09