[jOOQ/jOOQ#11061] [jOOQ/jOOQ#11070] [jOOQ/jOOQ#11091] WIP
This commit is contained in:
parent
e137636a9e
commit
5b1e7eb50f
108
jOOQ/src/main/java/org/jooq/impl/BitLength.java
Normal file
108
jOOQ/src/main/java/org/jooq/impl/BitLength.java
Normal file
@ -0,0 +1,108 @@
|
||||
/*
|
||||
* 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.
|
||||
*
|
||||
* Other licenses:
|
||||
* -----------------------------------------------------------------------------
|
||||
* Commercial licenses for this work are available. These replace the above
|
||||
* ASL 2.0 and offer limited warranties, support, maintenance, and commercial
|
||||
* database integrations.
|
||||
*
|
||||
* For more information, please visit: http://www.jooq.org/licenses
|
||||
*
|
||||
*
|
||||
*
|
||||
*
|
||||
*
|
||||
*
|
||||
*
|
||||
*
|
||||
*
|
||||
*
|
||||
*
|
||||
*
|
||||
*
|
||||
*
|
||||
*
|
||||
*
|
||||
*/
|
||||
package org.jooq.impl;
|
||||
|
||||
import static org.jooq.impl.DSL.function;
|
||||
import static org.jooq.impl.DSL.inline;
|
||||
import static org.jooq.impl.Names.N_BIT_LENGTH;
|
||||
import static org.jooq.impl.Names.N_CHAR_LENGTH;
|
||||
import static org.jooq.impl.Names.N_DATALENGTH;
|
||||
import static org.jooq.impl.Names.N_LEN;
|
||||
import static org.jooq.impl.Names.N_LENGTH;
|
||||
import static org.jooq.impl.Names.N_LENGTHB;
|
||||
import static org.jooq.impl.SQLDataType.INTEGER;
|
||||
import static org.jooq.impl.SQLDataType.VARCHAR;
|
||||
import static org.jooq.impl.Tools.nullSafeNotNull;
|
||||
|
||||
import org.jooq.Context;
|
||||
import org.jooq.Field;
|
||||
|
||||
/**
|
||||
* @author Lukas Eder
|
||||
*/
|
||||
final class BitLength extends AbstractField<Integer> {
|
||||
|
||||
/**
|
||||
* Generated UID
|
||||
*/
|
||||
private static final long serialVersionUID = 1484652553287331042L;
|
||||
|
||||
private final Field<String> field;
|
||||
|
||||
BitLength(Field<String> field) {
|
||||
super(N_BIT_LENGTH, INTEGER.nullable(field == null || field.getDataType().nullable()));
|
||||
|
||||
this.field = nullSafeNotNull(field, VARCHAR);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void accept(Context<?> ctx) {
|
||||
switch (ctx.family()) {
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
case DERBY:
|
||||
case SQLITE:
|
||||
ctx.visit(inline(8).times(function(N_LENGTH, getDataType(), field)));
|
||||
break;
|
||||
|
||||
default:
|
||||
ctx.visit(function(N_BIT_LENGTH, getDataType(), field));
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
97
jOOQ/src/main/java/org/jooq/impl/CharLength.java
Normal file
97
jOOQ/src/main/java/org/jooq/impl/CharLength.java
Normal file
@ -0,0 +1,97 @@
|
||||
/*
|
||||
* 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.
|
||||
*
|
||||
* Other licenses:
|
||||
* -----------------------------------------------------------------------------
|
||||
* Commercial licenses for this work are available. These replace the above
|
||||
* ASL 2.0 and offer limited warranties, support, maintenance, and commercial
|
||||
* database integrations.
|
||||
*
|
||||
* For more information, please visit: http://www.jooq.org/licenses
|
||||
*
|
||||
*
|
||||
*
|
||||
*
|
||||
*
|
||||
*
|
||||
*
|
||||
*
|
||||
*
|
||||
*
|
||||
*
|
||||
*
|
||||
*
|
||||
*
|
||||
*
|
||||
*
|
||||
*/
|
||||
package org.jooq.impl;
|
||||
|
||||
import static org.jooq.impl.DSL.function;
|
||||
import static org.jooq.impl.Names.N_BIT_LENGTH;
|
||||
import static org.jooq.impl.Names.N_CHAR_LENGTH;
|
||||
import static org.jooq.impl.Names.N_LEN;
|
||||
import static org.jooq.impl.Names.N_LENGTH;
|
||||
import static org.jooq.impl.SQLDataType.INTEGER;
|
||||
import static org.jooq.impl.SQLDataType.VARCHAR;
|
||||
import static org.jooq.impl.Tools.nullSafeNotNull;
|
||||
|
||||
import org.jooq.Context;
|
||||
import org.jooq.Field;
|
||||
|
||||
/**
|
||||
* @author Lukas Eder
|
||||
*/
|
||||
final class CharLength extends AbstractField<Integer> {
|
||||
|
||||
/**
|
||||
* Generated UID
|
||||
*/
|
||||
private static final long serialVersionUID = 1484652553287331042L;
|
||||
|
||||
private final Field<String> field;
|
||||
|
||||
CharLength(Field<String> field) {
|
||||
super(N_CHAR_LENGTH, INTEGER.nullable(field == null || field.getDataType().nullable()));
|
||||
|
||||
this.field = nullSafeNotNull(field, VARCHAR);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void accept(Context<?> ctx) {
|
||||
switch (ctx.family()) {
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
case DERBY:
|
||||
case SQLITE:
|
||||
ctx.visit(function(N_LENGTH, getDataType(), field));
|
||||
break;
|
||||
|
||||
default:
|
||||
ctx.visit(function(N_CHAR_LENGTH, getDataType(), field));
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -15224,7 +15224,7 @@ public class DSL {
|
||||
@NotNull
|
||||
@Support({ CUBRID, FIREBIRD, H2, HSQLDB, MARIADB, MYSQL, POSTGRES, SQLITE })
|
||||
public static Field<String> repeat(String field, Field<? extends Number> count) {
|
||||
return repeat(Tools.field(field), Tools.nullSafe(count));
|
||||
return repeat(Tools.field(field), count);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -15235,7 +15235,7 @@ public class DSL {
|
||||
@NotNull
|
||||
@Support({ CUBRID, FIREBIRD, H2, HSQLDB, MARIADB, MYSQL, POSTGRES, SQLITE })
|
||||
public static Field<String> repeat(Field<String> field, int count) {
|
||||
return repeat(Tools.nullSafe(field), Tools.field(count));
|
||||
return repeat(field, Tools.field(count));
|
||||
}
|
||||
|
||||
/**
|
||||
@ -15254,7 +15254,7 @@ public class DSL {
|
||||
@NotNull
|
||||
@Support({ CUBRID, FIREBIRD, H2, HSQLDB, MARIADB, MYSQL, POSTGRES, SQLITE })
|
||||
public static Field<String> repeat(Field<String> field, Field<? extends Number> count) {
|
||||
return new Repeat(Tools.nullSafe(field), Tools.nullSafe(count));
|
||||
return new Repeat(field, count);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -15269,7 +15269,7 @@ public class DSL {
|
||||
@NotNull
|
||||
@Support({ CUBRID, FIREBIRD, H2, HSQLDB, MARIADB, MYSQL, POSTGRES, SQLITE })
|
||||
public static Field<String> space(int value) {
|
||||
return space(val(value));
|
||||
return space(Tools.field(value));
|
||||
}
|
||||
|
||||
/**
|
||||
@ -15284,7 +15284,7 @@ public class DSL {
|
||||
@NotNull
|
||||
@Support({ CUBRID, FIREBIRD, H2, HSQLDB, MARIADB, MYSQL, POSTGRES, SQLITE })
|
||||
public static Field<String> space(Field<Integer> value) {
|
||||
return new Space(Tools.nullSafe(value));
|
||||
return new Space(value);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -15302,7 +15302,7 @@ public class DSL {
|
||||
@NotNull
|
||||
@Support({ CUBRID, HSQLDB, MARIADB, MYSQL, POSTGRES })
|
||||
public static Field<String> reverse(Field<String> field) {
|
||||
return new Reverse(Tools.nullSafe(field));
|
||||
return new Reverse(field);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -15821,7 +15821,7 @@ public class DSL {
|
||||
@NotNull
|
||||
@Support
|
||||
public static Field<String> left(String field, Field<? extends Number> length) {
|
||||
return left(Tools.field(field), Tools.nullSafe(length));
|
||||
return left(Tools.field(field), length);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -15835,7 +15835,7 @@ public class DSL {
|
||||
@NotNull
|
||||
@Support
|
||||
public static Field<String> left(Field<String> field, int length) {
|
||||
return left(Tools.nullSafe(field), Tools.field(length));
|
||||
return left(field, Tools.field(length));
|
||||
}
|
||||
|
||||
/**
|
||||
@ -15877,7 +15877,7 @@ public class DSL {
|
||||
@NotNull
|
||||
@Support
|
||||
public static Field<String> right(String field, Field<? extends Number> length) {
|
||||
return right(Tools.field(field), Tools.nullSafe(length));
|
||||
return right(Tools.field(field), length);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -15891,7 +15891,7 @@ public class DSL {
|
||||
@NotNull
|
||||
@Support
|
||||
public static Field<String> right(Field<String> field, int length) {
|
||||
return right(Tools.nullSafe(field), Tools.field(length));
|
||||
return right(field, Tools.field(length));
|
||||
}
|
||||
|
||||
/**
|
||||
@ -15951,7 +15951,7 @@ public class DSL {
|
||||
@NotNull
|
||||
@Support
|
||||
public static Field<Integer> charLength(Field<String> field) {
|
||||
return new DefaultAggregateFunction<>(Term.CHAR_LENGTH, INTEGER.nullable(Tools.nullSafeDataType(field).nullable()), Tools.nullSafe(field));
|
||||
return new CharLength(field);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -15973,7 +15973,7 @@ public class DSL {
|
||||
@NotNull
|
||||
@Support
|
||||
public static Field<Integer> bitLength(Field<String> field) {
|
||||
return new DefaultAggregateFunction<>(Term.BIT_LENGTH, INTEGER.nullable(Tools.nullSafeDataType(field).nullable()), Tools.nullSafe(field));
|
||||
return new BitLength(field);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -15995,7 +15995,7 @@ public class DSL {
|
||||
@NotNull
|
||||
@Support
|
||||
public static Field<Integer> octetLength(Field<String> field) {
|
||||
return new DefaultAggregateFunction<>(Term.OCTET_LENGTH, INTEGER.nullable(Tools.nullSafeDataType(field).nullable()), Tools.nullSafe(field));
|
||||
return new OctetLength(field);
|
||||
}
|
||||
|
||||
// ------------------------------------------------------------------------
|
||||
|
||||
@ -39,8 +39,10 @@ package org.jooq.impl;
|
||||
|
||||
import static org.jooq.impl.DSL.inline;
|
||||
import static org.jooq.impl.Names.N_LEFT;
|
||||
import static org.jooq.impl.SQLDataType.INTEGER;
|
||||
import static org.jooq.impl.SQLDataType.VARCHAR;
|
||||
import static org.jooq.impl.Tools.allNotNull;
|
||||
import static org.jooq.impl.Tools.nullSafeNotNull;
|
||||
|
||||
import org.jooq.Context;
|
||||
import org.jooq.Field;
|
||||
@ -61,8 +63,8 @@ final class Left extends AbstractField<String> {
|
||||
Left(Field<String> field, Field<? extends Number> length) {
|
||||
super(N_LEFT, allNotNull(VARCHAR, field, length));
|
||||
|
||||
this.field = field;
|
||||
this.length = length;
|
||||
this.field = nullSafeNotNull(field, VARCHAR);
|
||||
this.length = nullSafeNotNull(length, INTEGER);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@ -68,6 +68,7 @@ final class Names {
|
||||
static final Name N_ATAN = unquotedName("atan");
|
||||
static final Name N_ATN = unquotedName("atn");
|
||||
static final Name N_BIT_COUNT = unquotedName("bit_count");
|
||||
static final Name N_BIT_LENGTH = unquotedName("bit_length");
|
||||
static final Name N_BOOL_AND = unquotedName("bool_and");
|
||||
static final Name N_BOOL_OR = unquotedName("bool_or");
|
||||
static final Name N_CARDINALITY = unquotedName("cardinality");
|
||||
@ -75,6 +76,7 @@ final class Names {
|
||||
static final Name N_CAST = unquotedName("cast");
|
||||
static final Name N_CEIL = unquotedName("ceil");
|
||||
static final Name N_CEILING = unquotedName("ceiling");
|
||||
static final Name N_CHAR_LENGTH = unquotedName("char_length");
|
||||
static final Name N_CHARINDEX = unquotedName("charindex");
|
||||
static final Name N_CHOOSE = unquotedName("choose");
|
||||
static final Name N_CLNG = unquotedName("clng");
|
||||
@ -96,6 +98,7 @@ final class Names {
|
||||
static final Name N_CURRENT_USER = unquotedName("current_user");
|
||||
static final Name N_CURRENTUSER = unquotedName("currentuser");
|
||||
static final Name N_CURRVAL = unquotedName("currval");
|
||||
static final Name N_DATALENGTH = unquotedName("datalength");
|
||||
static final Name N_DATE_ADD = unquotedName("date_add");
|
||||
static final Name N_DATE_DIFF = unquotedName("date_diff");
|
||||
static final Name N_DATE_TRUNC = unquotedName("date_trunc");
|
||||
@ -157,6 +160,7 @@ final class Names {
|
||||
static final Name N_LEFT = unquotedName("left");
|
||||
static final Name N_LEN = unquotedName("len");
|
||||
static final Name N_LENGTH = unquotedName("length");
|
||||
static final Name N_LENGTHB = unquotedName("lengthb");
|
||||
static final Name N_LIST = unquotedName("list");
|
||||
static final Name N_LISTAGG = unquotedName("listagg");
|
||||
static final Name N_LN = unquotedName("ln");
|
||||
@ -178,6 +182,7 @@ final class Names {
|
||||
static final Name N_NUMTODSINTERVAL = unquotedName("numtodsinterval");
|
||||
static final Name N_NVL = unquotedName("nvl");
|
||||
static final Name N_NVL2 = unquotedName("nvl2");
|
||||
static final Name N_OCTET_LENGTH = unquotedName("octet_length");
|
||||
static final Name N_OPENJSON = unquotedName("openjson");
|
||||
static final Name N_OPENXML = unquotedName("openxml");
|
||||
static final Name N_OVERLAY = unquotedName("overlay");
|
||||
|
||||
104
jOOQ/src/main/java/org/jooq/impl/OctetLength.java
Normal file
104
jOOQ/src/main/java/org/jooq/impl/OctetLength.java
Normal file
@ -0,0 +1,104 @@
|
||||
/*
|
||||
* 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.
|
||||
*
|
||||
* Other licenses:
|
||||
* -----------------------------------------------------------------------------
|
||||
* Commercial licenses for this work are available. These replace the above
|
||||
* ASL 2.0 and offer limited warranties, support, maintenance, and commercial
|
||||
* database integrations.
|
||||
*
|
||||
* For more information, please visit: http://www.jooq.org/licenses
|
||||
*
|
||||
*
|
||||
*
|
||||
*
|
||||
*
|
||||
*
|
||||
*
|
||||
*
|
||||
*
|
||||
*
|
||||
*
|
||||
*
|
||||
*
|
||||
*
|
||||
*
|
||||
*
|
||||
*/
|
||||
package org.jooq.impl;
|
||||
|
||||
import static org.jooq.impl.DSL.function;
|
||||
import static org.jooq.impl.DSL.inline;
|
||||
import static org.jooq.impl.Names.N_BIT_LENGTH;
|
||||
import static org.jooq.impl.Names.N_CHAR_LENGTH;
|
||||
import static org.jooq.impl.Names.N_DATALENGTH;
|
||||
import static org.jooq.impl.Names.N_LEN;
|
||||
import static org.jooq.impl.Names.N_LENGTH;
|
||||
import static org.jooq.impl.Names.N_LENGTHB;
|
||||
import static org.jooq.impl.Names.N_OCTET_LENGTH;
|
||||
import static org.jooq.impl.SQLDataType.INTEGER;
|
||||
import static org.jooq.impl.SQLDataType.VARCHAR;
|
||||
import static org.jooq.impl.Tools.nullSafeNotNull;
|
||||
|
||||
import org.jooq.Context;
|
||||
import org.jooq.Field;
|
||||
|
||||
/**
|
||||
* @author Lukas Eder
|
||||
*/
|
||||
final class OctetLength extends AbstractField<Integer> {
|
||||
|
||||
/**
|
||||
* Generated UID
|
||||
*/
|
||||
private static final long serialVersionUID = 1484652553287331042L;
|
||||
|
||||
private final Field<String> field;
|
||||
|
||||
OctetLength(Field<String> field) {
|
||||
super(N_BIT_LENGTH, INTEGER.nullable(field == null || field.getDataType().nullable()));
|
||||
|
||||
this.field = nullSafeNotNull(field, VARCHAR);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void accept(Context<?> ctx) {
|
||||
switch (ctx.family()) {
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
case DERBY:
|
||||
case SQLITE:
|
||||
ctx.visit(function(N_LENGTH, getDataType(), field));
|
||||
break;
|
||||
|
||||
default:
|
||||
ctx.visit(function(N_OCTET_LENGTH, getDataType(), field));
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -43,8 +43,10 @@ import static org.jooq.impl.Names.N_REPEAT;
|
||||
import static org.jooq.impl.Names.N_REPLACE;
|
||||
import static org.jooq.impl.Names.N_REPLICATE;
|
||||
import static org.jooq.impl.Names.N_ZEROBLOB;
|
||||
import static org.jooq.impl.SQLDataType.INTEGER;
|
||||
import static org.jooq.impl.SQLDataType.VARCHAR;
|
||||
import static org.jooq.impl.Tools.allNotNull;
|
||||
import static org.jooq.impl.Tools.nullSafeNotNull;
|
||||
|
||||
import org.jooq.Context;
|
||||
import org.jooq.Field;
|
||||
@ -65,8 +67,8 @@ final class Repeat extends AbstractField<String> {
|
||||
Repeat(Field<String> string, Field<? extends Number> count) {
|
||||
super(N_REPEAT, allNotNull(VARCHAR, string, count));
|
||||
|
||||
this.string = string;
|
||||
this.count = count;
|
||||
this.string = nullSafeNotNull(string, VARCHAR);
|
||||
this.count = nullSafeNotNull(count, INTEGER);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@ -39,6 +39,8 @@ package org.jooq.impl;
|
||||
|
||||
import static org.jooq.impl.Names.N_REVERSE;
|
||||
import static org.jooq.impl.Names.N_STRREVERSE;
|
||||
import static org.jooq.impl.SQLDataType.VARCHAR;
|
||||
import static org.jooq.impl.Tools.nullSafeNotNull;
|
||||
|
||||
import org.jooq.Context;
|
||||
import org.jooq.Field;
|
||||
@ -55,9 +57,9 @@ final class Reverse extends AbstractField<String> {
|
||||
private final Field<String> field;
|
||||
|
||||
Reverse(Field<String> field) {
|
||||
super(N_REVERSE, field.getDataType());
|
||||
super(N_REVERSE, field == null ? VARCHAR : field.getDataType());
|
||||
|
||||
this.field = field;
|
||||
this.field = nullSafeNotNull(field, VARCHAR);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@ -41,8 +41,10 @@ import static org.jooq.impl.DSL.one;
|
||||
import static org.jooq.impl.Internal.iadd;
|
||||
import static org.jooq.impl.Internal.isub;
|
||||
import static org.jooq.impl.Names.N_RIGHT;
|
||||
import static org.jooq.impl.SQLDataType.INTEGER;
|
||||
import static org.jooq.impl.SQLDataType.VARCHAR;
|
||||
import static org.jooq.impl.Tools.allNotNull;
|
||||
import static org.jooq.impl.Tools.nullSafeNotNull;
|
||||
|
||||
import org.jooq.Context;
|
||||
import org.jooq.Field;
|
||||
@ -63,8 +65,8 @@ final class Right extends AbstractField<String> {
|
||||
Right(Field<String> field, Field<? extends Number> length) {
|
||||
super(N_RIGHT, allNotNull(VARCHAR, field, length));
|
||||
|
||||
this.field = field;
|
||||
this.length = length;
|
||||
this.field = nullSafeNotNull(field, VARCHAR);
|
||||
this.length = nullSafeNotNull(length, INTEGER);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@ -38,7 +38,9 @@
|
||||
package org.jooq.impl;
|
||||
|
||||
import static org.jooq.impl.Names.N_SPACE;
|
||||
import static org.jooq.impl.SQLDataType.INTEGER;
|
||||
import static org.jooq.impl.SQLDataType.VARCHAR;
|
||||
import static org.jooq.impl.Tools.nullSafeNotNull;
|
||||
|
||||
import org.jooq.Context;
|
||||
import org.jooq.Field;
|
||||
@ -53,9 +55,9 @@ final class Space extends AbstractField<String> {
|
||||
private final Field<Integer> count;
|
||||
|
||||
Space(Field<Integer> count) {
|
||||
super(N_SPACE, VARCHAR.nullable(count.getDataType().nullable()));
|
||||
super(N_SPACE, VARCHAR.nullable(count == null || count.getDataType().nullable()));
|
||||
|
||||
this.count = count;
|
||||
this.count = nullSafeNotNull(count, INTEGER);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@ -48,6 +48,7 @@ import static org.jooq.impl.SQLDataType.VARCHAR;
|
||||
import static org.jooq.impl.Tools.allNotNull;
|
||||
import static org.jooq.impl.Tools.convertVal;
|
||||
import static org.jooq.impl.Tools.nullSafe;
|
||||
import static org.jooq.impl.Tools.nullSafeNotNull;
|
||||
import static org.jooq.impl.Tools.nullableIf;
|
||||
|
||||
import org.jooq.Context;
|
||||
@ -72,17 +73,17 @@ final class Substring extends AbstractField<String> {
|
||||
Substring(Field<String> field, Field<? extends Number> startingPosition) {
|
||||
super(N_SUBSTRING, allNotNull(VARCHAR, field, startingPosition));
|
||||
|
||||
this.field = nullableIf(false, nullSafe(field, VARCHAR));
|
||||
this.startingPosition = nullableIf(false, nullSafe(startingPosition, INTEGER));
|
||||
this.field = nullSafeNotNull(field, VARCHAR);
|
||||
this.startingPosition = nullSafeNotNull(startingPosition, INTEGER);
|
||||
this.length = null;
|
||||
}
|
||||
|
||||
Substring(Field<String> field, Field<? extends Number> startingPosition, Field<? extends Number> length) {
|
||||
super(N_SUBSTRING, allNotNull(VARCHAR, field, startingPosition, length));
|
||||
|
||||
this.field = nullableIf(false, nullSafe(field, VARCHAR));
|
||||
this.startingPosition = nullableIf(false, nullSafe(startingPosition, INTEGER));
|
||||
this.length = nullableIf(false, nullSafe(length, INTEGER));
|
||||
this.field = nullSafeNotNull(field, VARCHAR);
|
||||
this.startingPosition = nullSafeNotNull(startingPosition, INTEGER);
|
||||
this.length = nullSafeNotNull(length, INTEGER);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@ -46,7 +46,9 @@ import org.jooq.SQLDialect;
|
||||
* dialect-specific variants if applicable
|
||||
*
|
||||
* @author Lukas Eder
|
||||
* @deprecated - This should be removed by jOOQ 3.15.0
|
||||
*/
|
||||
@Deprecated
|
||||
enum Term {
|
||||
|
||||
ATAN2 {
|
||||
@ -64,89 +66,6 @@ enum Term {
|
||||
return "atan2";
|
||||
}
|
||||
},
|
||||
BIT_LENGTH {
|
||||
@Override
|
||||
public String translate(SQLDialect dialect) {
|
||||
switch (dialect.family()) {
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
case DERBY:
|
||||
case SQLITE:
|
||||
return "8 * length";
|
||||
}
|
||||
|
||||
return "bit_length";
|
||||
}
|
||||
},
|
||||
CHAR_LENGTH {
|
||||
@Override
|
||||
public String translate(SQLDialect dialect) {
|
||||
switch (dialect.family()) {
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
case DERBY:
|
||||
case SQLITE:
|
||||
return "length";
|
||||
}
|
||||
|
||||
return "char_length";
|
||||
}
|
||||
},
|
||||
OCTET_LENGTH {
|
||||
@Override
|
||||
public String translate(SQLDialect dialect) {
|
||||
switch (dialect.family()) {
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
case DERBY:
|
||||
case SQLITE:
|
||||
return "length";
|
||||
}
|
||||
|
||||
return "octet_length";
|
||||
}
|
||||
},
|
||||
STDDEV_POP {
|
||||
@Override
|
||||
public String translate(SQLDialect dialect) {
|
||||
|
||||
@ -5900,7 +5900,11 @@ final class Tools {
|
||||
}
|
||||
|
||||
static final DataType<?> dataType(Field<?> field) {
|
||||
return field == null ? OTHER : field.getDataType();
|
||||
return dataType(OTHER, field);
|
||||
}
|
||||
|
||||
static final DataType<?> dataType(DataType<?> defaultType, Field<?> field) {
|
||||
return field == null ? defaultType : field.getDataType();
|
||||
}
|
||||
|
||||
static final <T> DataType<T> allNotNull(DataType<T> defaultType, Field<T> f1, Field<?> f2) {
|
||||
@ -6022,6 +6026,10 @@ final class Tools {
|
||||
return (DataType<T>) (field == null ? SQLDataType.OTHER : field.getDataType());
|
||||
}
|
||||
|
||||
static final <T> Field<T> nullSafeNotNull(Field<T> field, DataType<?> type) {
|
||||
return nullableIf(false, nullSafe(field, type));
|
||||
}
|
||||
|
||||
static final <T> Field<T> nullableIf(boolean nullable, Field<T> field) {
|
||||
return isVal(field)
|
||||
? extractVal(field).convertTo(field.getDataType().nullable(nullable))
|
||||
|
||||
Loading…
Reference in New Issue
Block a user