diff --git a/mybatis-flex-core/src/main/java/com/mybatisflex/core/update/UpdateChain.java b/mybatis-flex-core/src/main/java/com/mybatisflex/core/update/UpdateChain.java index f8192e4d..99dc62e6 100644 --- a/mybatis-flex-core/src/main/java/com/mybatisflex/core/update/UpdateChain.java +++ b/mybatis-flex-core/src/main/java/com/mybatisflex/core/update/UpdateChain.java @@ -92,12 +92,12 @@ public class UpdateChain extends QueryWrapperAdapter> { return this; } - public UpdateChain set(LambdaGetter getter, Object value, boolean condition) { + public UpdateChain set(LambdaGetter getter, Object value, boolean condition) { entityWrapper.set(getter, value, condition); return this; } - public UpdateChain set(LambdaGetter getter, Object value) { + public UpdateChain set(LambdaGetter getter, Object value) { entityWrapper.set(getter, value); return this; } @@ -123,12 +123,12 @@ public class UpdateChain extends QueryWrapperAdapter> { return this; } - public UpdateChain setRaw(LambdaGetter getter, Object value, boolean condition) { + public UpdateChain setRaw(LambdaGetter getter, Object value, boolean condition) { entityWrapper.setRaw(getter, value, condition); return this; } - public UpdateChain setRaw(LambdaGetter getter, Object value) { + public UpdateChain setRaw(LambdaGetter getter, Object value) { entityWrapper.setRaw(getter, value); return this; } diff --git a/mybatis-flex-test/mybatis-flex-native-test/src/main/java/com/mybatisflex/test/UpdateChainTest.java b/mybatis-flex-test/mybatis-flex-native-test/src/main/java/com/mybatisflex/test/UpdateChainTest.java index 50eabe41..f1e13e48 100644 --- a/mybatis-flex-test/mybatis-flex-native-test/src/main/java/com/mybatisflex/test/UpdateChainTest.java +++ b/mybatis-flex-test/mybatis-flex-native-test/src/main/java/com/mybatisflex/test/UpdateChainTest.java @@ -1,3 +1,19 @@ +/* + * Copyright (c) 2022-2023, Mybatis-Flex (fuhai999@gmail.com). + *

+ * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + *

+ * http://www.apache.org/licenses/LICENSE-2.0 + *

+ * 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 + * limitations under the License. + */ + package com.mybatisflex.test; import com.mybatisflex.core.MybatisFlexBootstrap; @@ -15,6 +31,7 @@ import org.springframework.jdbc.datasource.embedded.EmbeddedDatabaseType; import javax.sql.DataSource; import static com.mybatisflex.test.table.AccountTableDef.ACCOUNT; +import static com.mybatisflex.test.table.ArticleTableDef.ARTICLE; public class UpdateChainTest { @@ -69,4 +86,17 @@ public class UpdateChainTest { .list() .forEach(System.out::println); } + + @Test + public void testUpdateChainToSql() { + String sql = UpdateChain.of(Account.class) + .set(ACCOUNT.AGE, 18) + .set(Article::getAccountId, 4, 1 == 1) + .leftJoin(ARTICLE).on(ACCOUNT.ID.eq(ARTICLE.ACCOUNT_ID)) + .where(ACCOUNT.ID.eq(4)) + .toSQL(); + + System.out.println(sql); + } + }