Skip to content

Commit c13c9ae

Browse files
committed
Add ValueOrNull mapping to GeneralInsertDSL
1 parent 2d7bebb commit c13c9ae

File tree

1 file changed

+11
-1
lines changed

1 file changed

+11
-1
lines changed

src/main/java/org/mybatis/dynamic/sql/insert/GeneralInsertDSL.java

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2016-2020 the original author or authors.
2+
* Copyright 2016-2021 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -29,6 +29,7 @@
2929
import org.mybatis.dynamic.sql.util.NullMapping;
3030
import org.mybatis.dynamic.sql.util.StringConstantMapping;
3131
import org.mybatis.dynamic.sql.util.ValueMapping;
32+
import org.mybatis.dynamic.sql.util.ValueOrNullMapping;
3233
import org.mybatis.dynamic.sql.util.ValueWhenPresentMapping;
3334

3435
public class GeneralInsertDSL implements Buildable<GeneralInsertModel> {
@@ -88,6 +89,15 @@ public GeneralInsertDSL toValue(Supplier<T> valueSupplier) {
8889
return GeneralInsertDSL.this;
8990
}
9091

92+
public GeneralInsertDSL toValueOrNull(T value) {
93+
return toValueOrNull(() -> value);
94+
}
95+
96+
public GeneralInsertDSL toValueOrNull(Supplier<T> valueSupplier) {
97+
insertMappings.add(ValueOrNullMapping.of(column, valueSupplier));
98+
return GeneralInsertDSL.this;
99+
}
100+
91101
public GeneralInsertDSL toValueWhenPresent(T value) {
92102
return toValueWhenPresent(() -> value);
93103
}

0 commit comments

Comments
 (0)