Skip to content

Commit

Permalink
Fixed #522.
Browse files Browse the repository at this point in the history
  • Loading branch information
haocao committed Dec 28, 2017
1 parent fb66859 commit 487fe70
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 2 deletions.
1 change: 1 addition & 0 deletions RELEASE-NOTES.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
### 缺陷修正
1. [ISSUE #520](https://github.com/shardingjdbc/sharding-jdbc/issues/520) 引入分表后,唯一键冲突时异常类型不再是DuplicateKeyException
1. [ISSUE #521](https://github.com/shardingjdbc/sharding-jdbc/issues/521) YAML文件中ShardingProperties设置无效
1. [ISSUE #522](https://github.com/shardingjdbc/sharding-jdbc/issues/522) 读写分离Slave库不需要执行DDL语句

## 2.0.1

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,15 +51,15 @@ public final class MasterSlaveConnection extends AbstractConnectionAdapter {
/**
* Get database connections via SQL type.
*
* <p>DDL will return all connections; DQL will return slave connection; DML or updated before in same thread will return master connection.</p>
* <p>DDL will return master connection; DQL will return slave connection; DML or updated before in same thread will return master connection.</p>
*
* @param sqlType SQL type
* @return database connections via SQL type
* @throws SQLException SQL exception
*/
public Collection<Connection> getConnections(final SQLType sqlType) throws SQLException {
cachedSQLType = sqlType;
Map<String, DataSource> dataSources = SQLType.DDL == sqlType ? masterSlaveDataSource.getAllDataSources() : masterSlaveDataSource.getDataSource(sqlType).toMap();
Map<String, DataSource> dataSources = SQLType.DDL == sqlType ? masterSlaveDataSource.getMasterDataSource() : masterSlaveDataSource.getDataSource(sqlType).toMap();
Collection<Connection> result = new LinkedList<>();
for (Entry<String, DataSource> each : dataSources.entrySet()) {
String dataSourceName = each.getKey();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,17 @@ public Map<String, DataSource> getAllDataSources() {
return result;
}

/**
* Get all master data sources.
*
* @return map of actual master data source name and actual master data sources
*/
public Map<String, DataSource> getMasterDataSource() {
Map<String, DataSource> result = new HashMap<>(1);
result.put(masterSlaveRule.getMasterDataSourceName(), masterSlaveRule.getMasterDataSource());
return result;
}

/**
* reset DML flag.
*/
Expand Down

0 comments on commit 487fe70

Please sign in to comment.