mirror of
https://gitee.com/mybatis-flex/mybatis-flex.git
synced 2025-12-08 01:28:24 +08:00
!264 feat: Lambda 支持 set join 列的值。
Merge pull request !264 from 王帅/main
This commit is contained in:
commit
2c7cb3f279
@ -92,12 +92,12 @@ public class UpdateChain<T> extends QueryWrapperAdapter<UpdateChain<T>> {
|
||||
return this;
|
||||
}
|
||||
|
||||
public UpdateChain<T> set(LambdaGetter<T> getter, Object value, boolean condition) {
|
||||
public <L> UpdateChain<T> set(LambdaGetter<L> getter, Object value, boolean condition) {
|
||||
entityWrapper.set(getter, value, condition);
|
||||
return this;
|
||||
}
|
||||
|
||||
public UpdateChain<T> set(LambdaGetter<T> getter, Object value) {
|
||||
public <L> UpdateChain<T> set(LambdaGetter<L> getter, Object value) {
|
||||
entityWrapper.set(getter, value);
|
||||
return this;
|
||||
}
|
||||
@ -123,12 +123,12 @@ public class UpdateChain<T> extends QueryWrapperAdapter<UpdateChain<T>> {
|
||||
return this;
|
||||
}
|
||||
|
||||
public UpdateChain<T> setRaw(LambdaGetter<T> getter, Object value, boolean condition) {
|
||||
public <L> UpdateChain<T> setRaw(LambdaGetter<L> getter, Object value, boolean condition) {
|
||||
entityWrapper.setRaw(getter, value, condition);
|
||||
return this;
|
||||
}
|
||||
|
||||
public UpdateChain<T> setRaw(LambdaGetter<T> getter, Object value) {
|
||||
public <L> UpdateChain<T> setRaw(LambdaGetter<L> getter, Object value) {
|
||||
entityWrapper.setRaw(getter, value);
|
||||
return this;
|
||||
}
|
||||
|
||||
@ -1,3 +1,19 @@
|
||||
/*
|
||||
* Copyright (c) 2022-2023, Mybatis-Flex (fuhai999@gmail.com).
|
||||
* <p>
|
||||
* 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
|
||||
* <p>
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
* <p>
|
||||
* 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);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user