TherChenYang opened a new pull request, #31378:
URL: https://github.com/apache/shardingsphere/pull/31378
Fixes #31360.
Changes proposed in this pull request:
- When we have configured the relevant table property configuration for
shadow in config.yaml, but our table has been
created ahead of time and not through ShardingSphereConection, an error is
thrown`TableNotFoundException: Table or view ‘t_order’ does not exist.`
- we should refer to the tables that are preloaded in the configuration
class in shadingRule, which can avoid this problem
For Example
- **Configuration file**
```yaml
mode:
type: Standalone
repository:
type: JDBC
props:
path: demo
dataSources:
ds_0:
dataSourceClassName: com.zaxxer.hikari.HikariDataSource
driverClassName: com.mysql.jdbc.Driver
jdbcUrl:
jdbc:mysql://localhost:3306/demo_ds_0?serverTimezone=UTC&useSSL=false&useUnicode=true&characterEncoding=UTF-8&allowPublicKeyRetrieval=true
username: root
password: mcycxc19740203
maxPoolSize: 10
ds_1:
dataSourceClassName: com.zaxxer.hikari.HikariDataSource
driverClassName: com.mysql.jdbc.Driver
jdbcUrl:
jdbc:mysql://localhost:3306/demo_ds_1?serverTimezone=UTC&useSSL=false&useUnicode=true&characterEncoding=UTF-8&allowPublicKeyRetrieval=true
username: root
password: mcycxc19740203
maxPoolSize: 10
rules:
- !SHADOW
tables:
t_order:
dataSourceNames:
- shadow_group
shadowAlgorithmNames:
- user_id_insert_match_algorithm
- user_id_delete_match_algorithm
- user_id_select_match_algorithm
dataSources:
shadow_group:
productionDataSourceName: ds_0
shadowDataSourceName: ds_1
shadowAlgorithms:
user_id_insert_match_algorithm:
type: REGEX_MATCH
props:
operation: insert
column: order_type
regex: "[1]"
user_id_delete_match_algorithm:
type: REGEX_MATCH
props:
operation: delete
column: order_type
regex: "[1]"
user_id_select_match_algorithm:
type: REGEX_MATCH
props:
operation: select
column: order_type
regex: "[1]"
props:
sql-show: true
```
- **Code**
<img width="481" alt="image"
src="https://github.com/apache/shardingsphere/assets/124348939/30af9eb6-7717-48a7-b092-987ebb83bcbb">
- **Exception**
<img width="1333" alt="image"
src="https://github.com/apache/shardingsphere/assets/124348939/a4cc803a-903c-471f-a50e-db5a6d3b64f6">
-- **After modification**
<img width="1360" alt="image"
src="https://github.com/apache/shardingsphere/assets/124348939/f024a861-b011-4833-99ce-71be30f2faaf">
---
Before committing this PR, I'm sure that I have checked the following
options:
- [x] My code follows the [code of
conduct](https://shardingsphere.apache.org/community/en/involved/conduct/code/)
of this project.
- [x] I have self-reviewed the commit code.
- [x] I have (or in comment I request) added corresponding labels for the
pull request.
- [x] I have passed maven check locally : `./mvnw clean install -B -T1C
-Dmaven.javadoc.skip -Dmaven.jacoco.skip -e`.
- [ ] I have made corresponding changes to the documentation.
- [ ] I have added corresponding unit tests for my changes.
--
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]