thswlsqls opened a new pull request, #39868:
URL: https://github.com/apache/shardingsphere/pull/39868

   
   Fixes #39867.
   
   Changes proposed in this pull request:
     - `ShardingConstraintReviser.getLogicIndex()` checks that the actual 
constraint name ends with `_<actualTable>` but strips it with 
`String.replace(suffix, "")`, which removes every occurrence of that token.
     - With database-only sharding (actual table name equals logic name) and a 
FK named after its table, `fk_t_order_item_order_t_order_item` is loaded as 
`fk_order` instead of `fk_t_order_item_order`; 
`MySQLShardingShowCreateTableMergedResult.replaceConstraints()` then searches 
for `fk_order_t_order_item` and leaves the actual FK name in the `SHOW CREATE 
TABLE` output.
     - Strip only the trailing suffix with `substring`, the exact inverse of 
`ConstraintToken.getConstraintValue()`, which appends `'_' + actualTable` once.
     - Same tail-only strip as 
`IndexMetaDataUtils.stripActualIndexNameSuffix()` used by the sibling 
`ShardingIndexReviser`; kept local because `ConstraintToken` builds the suffix 
locally rather than through `IndexMetaDataUtils`.
     - Add `assertReviseWhenConstraintNameContainsActualTableSuffix`, which 
fails on master (`foo_fk`) and passes with this change; existing cases are 
unchanged.
     - Verification scope: module-scoped `./mvnw install -pl 
features/sharding/core -am -B -T1C -Dmaven.javadoc.skip -Dmaven.jacoco.skip -e` 
(BUILD SUCCESS, 878 unit tests and 5 module ITs, 0 failures) plus 
spotless/checkstyle/apache-rat on the module; the full-repository `clean 
install` and E2E were not run locally.
   
   AI assistance: Claude Code was used to draft the change and its unit test in 
`features/sharding/core`. I reviewed, verified, and take responsibility for 
every line submitted.
   
   ---
   
   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.
   - [ ] I have (or in comment I request) added corresponding labels for the 
pull request.
   - [ ] I have passed maven check locally : `./mvnw clean install -B -T1C 
-Dmaven.javadoc.skip -Dmaven.jacoco.skip -e`. Ran the module-scoped equivalent 
instead: `./mvnw install -pl features/sharding/core -am -B -T1C 
-Dmaven.javadoc.skip -Dmaven.jacoco.skip -e` (BUILD SUCCESS) and 
`spotless:apply`, `checkstyle:check`, `apache-rat:check` with `-Pcheck -pl 
features/sharding/core`.
   - [ ] I have made corresponding changes to the documentation. No 
documentation describes constraint name revision; none needed.
   - [x] I have added corresponding unit tests for my changes.
   - [x] I have updated the Release Notes of the current development version. 
For more details, see [Update Release 
Note](https://shardingsphere.apache.org/community/en/involved/contribute/contributor/)
   - [x] I have disclosed the tool and affected files or scope for any material 
AI assistance, as required by the [AI-assisted contribution policy].
   
   [AI-assisted contribution policy]: 
https://github.com/apache/shardingsphere/blob/master/AI_POLICY.md
   
   


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

Reply via email to