diff --git a/RELEASE-NOTES.md b/RELEASE-NOTES.md index c709e1bc3ab02..697eedf306747 100644 --- a/RELEASE-NOTES.md +++ b/RELEASE-NOTES.md @@ -77,6 +77,7 @@ 1. Mode: Fix issue of drop schema can not work on standalone mode - [#34470](https://github.com/apache/shardingsphere/pull/34470) 1. Encrypt: Resolve rewrite issue in nested concat function - [#35815](https://github.com/apache/shardingsphere/pull/35815) 1. Sharding: Fix mod sharding algorithm judgement -[#36386](https://github.com/apache/shardingsphere/pull/36386) +1. Encrypt: Resolve the conflict between encrypted derived columns and primary key columns -[#36899](https://github.com/apache/shardingsphere/pull/36899) ### Change Logs diff --git a/infra/rewrite/core/src/main/java/org/apache/shardingsphere/infra/rewrite/sql/token/common/pojo/SQLToken.java b/infra/rewrite/core/src/main/java/org/apache/shardingsphere/infra/rewrite/sql/token/common/pojo/SQLToken.java index 809a1e47dabd9..d0929d28d2740 100644 --- a/infra/rewrite/core/src/main/java/org/apache/shardingsphere/infra/rewrite/sql/token/common/pojo/SQLToken.java +++ b/infra/rewrite/core/src/main/java/org/apache/shardingsphere/infra/rewrite/sql/token/common/pojo/SQLToken.java @@ -31,7 +31,11 @@ public abstract class SQLToken implements Comparable { @Override public final int compareTo(final SQLToken sqlToken) { - return startIndex - sqlToken.startIndex; + int value = startIndex - sqlToken.startIndex; + if (value == 0) { + return getSubSort() - sqlToken.getSubSort(); + } + return value; } /** @@ -40,4 +44,13 @@ public final int compareTo(final SQLToken sqlToken) { * @return stop index */ public abstract int getStopIndex(); + + /** + * When the startIndex is the same, sort according to subSort. + * + * @return sub sort. + */ + protected int getSubSort() { + return 0; + } } diff --git a/infra/rewrite/core/src/main/java/org/apache/shardingsphere/infra/rewrite/sql/token/keygen/pojo/GeneratedKeyInsertColumnToken.java b/infra/rewrite/core/src/main/java/org/apache/shardingsphere/infra/rewrite/sql/token/keygen/pojo/GeneratedKeyInsertColumnToken.java index 0f70e822163c6..d829f15851c7f 100644 --- a/infra/rewrite/core/src/main/java/org/apache/shardingsphere/infra/rewrite/sql/token/keygen/pojo/GeneratedKeyInsertColumnToken.java +++ b/infra/rewrite/core/src/main/java/org/apache/shardingsphere/infra/rewrite/sql/token/keygen/pojo/GeneratedKeyInsertColumnToken.java @@ -11,7 +11,7 @@ * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and + * See the License for the specif * limitations under the License. */ @@ -41,4 +41,12 @@ public String toString() { public int getStopIndex() { return getStartIndex(); } + + /** + * Make the GeneratedKeyInsertColumnToken appear later. + */ + @Override + protected int getSubSort() { + return 1; + } }