liuzg459 commented on issue #23839: URL: https://github.com/apache/shardingsphere/issues/23839#issuecomment-1408339289
我是参照 [https://github.com/apache/shardingsphere/issues/16725](https://github.com/apache/shardingsphere/issues/16725)的代码,执行`contextManager.alterRuleConfiguration(schemaName, newRuleConfigList);`后无法根据配置正常分页, 跟源码到: `ContextManager.alterRuleConfiguration`和`newShardingSphereDatabase`方法,发现`newShardingSphereDatabase`方法的`loadSchema`会调用H2数据库查询之前的schema,并设置到新的schema,原始代码如下: ``` result.put(originalDatabase.getName().toLowerCase(), new ShardingSphereDatabase(originalDatabase.getName(), originalDatabase.getProtocolType(), originalDatabase.getResource(), originalDatabase.getRuleMetaData(), metaDataContexts.getPersistService().getDatabaseMetaDataService().load(originalDatabase.getName()))); ``` `load`方法调用了H2数据库查询内存中的schema,但是并没有任何地方设置这个schema,所以是空的,将方法改成如下代码后,可正常调用(originalDatabase中保存的schema是正确的) ``` result.put(originalDatabase.getName().toLowerCase(), new ShardingSphereDatabase(originalDatabase.getName(), originalDatabase.getProtocolType(), originalDatabase.getResource(), originalDatabase.getRuleMetaData(), originalDatabase.getSchemas())); ``` -- 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: [email protected] For queries about this service, please contact Infrastructure at: [email protected]
