[jOOQ/jOOQ#11092] Deprecate DSL.nullSafe() and related protected methods, and move them to Tools
This commit is contained in:
parent
d1db74fc4b
commit
0e23dde879
@ -55,8 +55,6 @@ import static org.jooq.Comparator.NOT_LIKE_IGNORE_CASE;
|
||||
import static org.jooq.Comparator.NOT_SIMILAR_TO;
|
||||
import static org.jooq.Comparator.SIMILAR_TO;
|
||||
import static org.jooq.impl.DSL.inline;
|
||||
import static org.jooq.impl.DSL.nullSafe;
|
||||
import static org.jooq.impl.DSL.nullSafeList;
|
||||
import static org.jooq.impl.DSL.val;
|
||||
import static org.jooq.impl.ExpressionOperator.ADD;
|
||||
import static org.jooq.impl.ExpressionOperator.DIVIDE;
|
||||
@ -66,6 +64,8 @@ import static org.jooq.impl.Tools.EMPTY_FIELD;
|
||||
import static org.jooq.impl.Tools.EMPTY_STRING;
|
||||
import static org.jooq.impl.Tools.castIfNeeded;
|
||||
import static org.jooq.impl.Tools.fieldsArray;
|
||||
import static org.jooq.impl.Tools.nullSafe;
|
||||
import static org.jooq.impl.Tools.nullSafeList;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.sql.Timestamp;
|
||||
@ -74,13 +74,10 @@ import java.util.Collection;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Map.Entry;
|
||||
import java.util.function.Function;
|
||||
|
||||
import org.jooq.BetweenAndStep;
|
||||
import org.jooq.Binding;
|
||||
import org.jooq.CaseValueStep;
|
||||
import org.jooq.CaseWhenStep;
|
||||
import org.jooq.Clause;
|
||||
import org.jooq.Collation;
|
||||
import org.jooq.Comment;
|
||||
|
||||
@ -64,7 +64,6 @@ import static org.jooq.SQLDialect.SQLITE;
|
||||
// ...
|
||||
// ...
|
||||
// ...
|
||||
import static org.jooq.impl.DSL.nullSafe;
|
||||
import static org.jooq.impl.DSL.row;
|
||||
import static org.jooq.impl.DSL.val;
|
||||
import static org.jooq.impl.Keywords.K_AND;
|
||||
@ -72,6 +71,7 @@ import static org.jooq.impl.Keywords.K_BETWEEN;
|
||||
import static org.jooq.impl.Keywords.K_NOT;
|
||||
import static org.jooq.impl.Keywords.K_SYMMETRIC;
|
||||
import static org.jooq.impl.Tools.embeddedFields;
|
||||
import static org.jooq.impl.Tools.nullSafe;
|
||||
|
||||
import java.util.Set;
|
||||
|
||||
|
||||
@ -73,7 +73,6 @@ import static org.jooq.SQLDialect.SQLITE;
|
||||
// ...
|
||||
import static org.jooq.conf.ParamType.INLINED;
|
||||
import static org.jooq.impl.DSL.inline;
|
||||
import static org.jooq.impl.DSL.nullSafe;
|
||||
import static org.jooq.impl.DSL.row;
|
||||
import static org.jooq.impl.Keywords.K_AS;
|
||||
import static org.jooq.impl.Keywords.K_CAST;
|
||||
@ -81,6 +80,7 @@ import static org.jooq.impl.Keywords.K_ESCAPE;
|
||||
import static org.jooq.impl.Keywords.K_VARCHAR;
|
||||
import static org.jooq.impl.Tools.castIfNeeded;
|
||||
import static org.jooq.impl.Tools.embeddedFields;
|
||||
import static org.jooq.impl.Tools.nullSafe;
|
||||
|
||||
import java.util.Set;
|
||||
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@ -37,8 +37,11 @@
|
||||
*/
|
||||
package org.jooq.impl;
|
||||
|
||||
import static org.jooq.impl.DSL.nullSafe;
|
||||
import static org.jooq.impl.ExpressionOperator.*;
|
||||
import static org.jooq.impl.ExpressionOperator.ADD;
|
||||
import static org.jooq.impl.ExpressionOperator.DIVIDE;
|
||||
import static org.jooq.impl.ExpressionOperator.MULTIPLY;
|
||||
import static org.jooq.impl.ExpressionOperator.SUBTRACT;
|
||||
import static org.jooq.impl.Tools.nullSafe;
|
||||
|
||||
import org.jooq.Binding;
|
||||
import org.jooq.Check;
|
||||
|
||||
@ -60,7 +60,6 @@ import static org.jooq.impl.DSL.exists;
|
||||
import static org.jooq.impl.DSL.insertInto;
|
||||
import static org.jooq.impl.DSL.noCondition;
|
||||
import static org.jooq.impl.DSL.notExists;
|
||||
import static org.jooq.impl.DSL.nullSafe;
|
||||
import static org.jooq.impl.DSL.trueCondition;
|
||||
import static org.jooq.impl.DSL.when;
|
||||
import static org.jooq.impl.Keywords.K_AND;
|
||||
@ -83,6 +82,7 @@ import static org.jooq.impl.Keywords.K_WHERE;
|
||||
import static org.jooq.impl.Keywords.K_WITH_PRIMARY_KEY;
|
||||
import static org.jooq.impl.QueryPartListView.wrap;
|
||||
import static org.jooq.impl.Tools.EMPTY_FIELD;
|
||||
import static org.jooq.impl.Tools.nullSafe;
|
||||
import static org.jooq.impl.Tools.BooleanDataKey.DATA_WRAP_DERIVED_TABLES_IN_PARENTHESES;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
@ -38,9 +38,9 @@
|
||||
package org.jooq.impl;
|
||||
|
||||
import static org.jooq.impl.DSL.name;
|
||||
import static org.jooq.impl.DSL.nullSafeDataType;
|
||||
import static org.jooq.impl.Keywords.K_PRIOR;
|
||||
import static org.jooq.impl.Names.N_PRIOR;
|
||||
import static org.jooq.impl.Tools.nullSafeDataType;
|
||||
|
||||
import org.jooq.Context;
|
||||
import org.jooq.Field;
|
||||
|
||||
@ -98,7 +98,6 @@ import static org.jooq.impl.DSL.getDataType;
|
||||
import static org.jooq.impl.DSL.jsonEntry;
|
||||
import static org.jooq.impl.DSL.keyword;
|
||||
import static org.jooq.impl.DSL.name;
|
||||
import static org.jooq.impl.DSL.nullSafeDataType;
|
||||
import static org.jooq.impl.DSL.row;
|
||||
import static org.jooq.impl.DSL.select;
|
||||
import static org.jooq.impl.DSL.val;
|
||||
@ -5946,4 +5945,66 @@ final class Tools {
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
static final <T> Field<T> nullSafe(Field<T> field) {
|
||||
return field == null ? DSL.val((T) null) : field;
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
static final <T> Field<T> nullSafe(Field<T> field, DataType<?> type) {
|
||||
return field == null
|
||||
? (Field<T>) DSL.val((T) null, type)
|
||||
: field instanceof Val
|
||||
? (Field<T>) ((Val<T>) field).convertTo(type)
|
||||
: field;
|
||||
}
|
||||
|
||||
static final Field<?>[] nullSafe(Field<?>... fields) {
|
||||
if (fields == null)
|
||||
return EMPTY_FIELD;
|
||||
|
||||
Field<?>[] result = new Field<?>[fields.length];
|
||||
for (int i = 0; i < fields.length; i++)
|
||||
result[i] = nullSafe(fields[i]);
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
static final Field<?>[] nullSafe(Field<?>[] fields, DataType<?> type) {
|
||||
if (fields == null)
|
||||
return EMPTY_FIELD;
|
||||
|
||||
Field<?>[] result = new Field<?>[fields.length];
|
||||
for (int i = 0; i < fields.length; i++)
|
||||
result[i] = nullSafe(fields[i], type);
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
static final List<Field<?>> nullSafeList(Field<?>... fields) {
|
||||
if (fields == null)
|
||||
return asList(EMPTY_FIELD);
|
||||
|
||||
List<Field<?>> result = new ArrayList<>(fields.length);
|
||||
for (Field<?> f : fields)
|
||||
result.add(nullSafe(f));
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
static final List<Field<?>> nullSafeList(Field<?>[] fields, DataType<?> type) {
|
||||
if (fields == null)
|
||||
return asList(EMPTY_FIELD);
|
||||
|
||||
List<Field<?>> result = new ArrayList<>(fields.length);
|
||||
for (Field<?> f : fields)
|
||||
result.add(nullSafe(f, type));
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
static final <T> DataType<T> nullSafeDataType(Field<T> field) {
|
||||
return (DataType<T>) (field == null ? SQLDataType.OTHER : field.getDataType());
|
||||
}
|
||||
}
|
||||
|
||||
@ -37,24 +37,20 @@
|
||||
*/
|
||||
package org.jooq.util.postgres;
|
||||
|
||||
import org.jetbrains.annotations.*;
|
||||
|
||||
|
||||
// ...
|
||||
import static org.jooq.SQLDialect.POSTGRES;
|
||||
|
||||
import org.jooq.Condition;
|
||||
import org.jooq.DataType;
|
||||
import org.jooq.Field;
|
||||
import org.jooq.Record;
|
||||
import org.jooq.Record1;
|
||||
import org.jooq.SQLDialect;
|
||||
import org.jooq.Select;
|
||||
import org.jooq.Support;
|
||||
import org.jooq.Table;
|
||||
import org.jooq.impl.DSL;
|
||||
import org.jooq.impl.SQLDataType;
|
||||
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
/**
|
||||
* The {@link SQLDialect#POSTGRES} specific DSL.
|
||||
*
|
||||
|
||||
Loading…
Reference in New Issue
Block a user