[jOOQ/jOOQ#16101] Support binary BIT_LENGTH() and OCTET_LENGTH()

This commit is contained in:
Lukas Eder 2024-01-19 09:22:17 +01:00
parent 4e19b9799d
commit be43c31a8a
10 changed files with 1210 additions and 24 deletions

View File

@ -0,0 +1,156 @@
/*
* 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
*
* https://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: https://www.jooq.org/legal/licensing
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*/
package org.jooq.impl;
import static org.jooq.impl.DSL.*;
import static org.jooq.impl.Internal.*;
import static org.jooq.impl.Keywords.*;
import static org.jooq.impl.Names.*;
import static org.jooq.impl.SQLDataType.*;
import static org.jooq.impl.Tools.*;
import static org.jooq.impl.Tools.BooleanDataKey.*;
import static org.jooq.impl.Tools.ExtendedDataKey.*;
import static org.jooq.impl.Tools.SimpleDataKey.*;
import static org.jooq.SQLDialect.*;
import org.jooq.*;
import org.jooq.Function1;
import org.jooq.Record;
import org.jooq.conf.*;
import org.jooq.impl.*;
import org.jooq.impl.QOM.*;
import org.jooq.tools.*;
import java.util.*;
import java.util.function.*;
import java.util.stream.*;
/**
* The <code>BINARY BIT LENGTH</code> statement.
*/
@SuppressWarnings({ "rawtypes", "unchecked", "unused" })
final class BinaryBitLength
extends
AbstractField<Integer>
implements
QOM.BinaryBitLength
{
final Field<byte[]> bytes;
BinaryBitLength(
Field<byte[]> bytes
) {
super(
N_BINARY_BIT_LENGTH,
allNotNull(INTEGER, bytes)
);
this.bytes = nullSafeNotNull(bytes, VARBINARY);
}
// -------------------------------------------------------------------------
// XXX: QueryPart API
// -------------------------------------------------------------------------
@Override
final boolean parenthesised(Context<?> ctx) {
return true;
}
@Override
public final void accept(Context<?> ctx) {
switch (ctx.family()) {
default:
ctx.visit(function(N_BIT_LENGTH, getDataType(), bytes));
break;
}
}
// -------------------------------------------------------------------------
// XXX: Query Object Model
// -------------------------------------------------------------------------
@Override
public final Field<byte[]> $arg1() {
return bytes;
}
@Override
public final QOM.BinaryBitLength $arg1(Field<byte[]> newValue) {
return $constructor().apply(newValue);
}
@Override
public final Function1<? super Field<byte[]>, ? extends QOM.BinaryBitLength> $constructor() {
return (a1) -> new BinaryBitLength(a1);
}
// -------------------------------------------------------------------------
// XXX: The Object API
// -------------------------------------------------------------------------
@Override
public boolean equals(Object that) {
if (that instanceof QOM.BinaryBitLength o) {
return
StringUtils.equals($bytes(), o.$bytes())
;
}
else
return super.equals(that);
}
}

View File

@ -0,0 +1,156 @@
/*
* 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
*
* https://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: https://www.jooq.org/legal/licensing
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*/
package org.jooq.impl;
import static org.jooq.impl.DSL.*;
import static org.jooq.impl.Internal.*;
import static org.jooq.impl.Keywords.*;
import static org.jooq.impl.Names.*;
import static org.jooq.impl.SQLDataType.*;
import static org.jooq.impl.Tools.*;
import static org.jooq.impl.Tools.BooleanDataKey.*;
import static org.jooq.impl.Tools.ExtendedDataKey.*;
import static org.jooq.impl.Tools.SimpleDataKey.*;
import static org.jooq.SQLDialect.*;
import org.jooq.*;
import org.jooq.Function1;
import org.jooq.Record;
import org.jooq.conf.*;
import org.jooq.impl.*;
import org.jooq.impl.QOM.*;
import org.jooq.tools.*;
import java.util.*;
import java.util.function.*;
import java.util.stream.*;
/**
* The <code>BINARY LENGTH</code> statement.
*/
@SuppressWarnings({ "rawtypes", "unchecked", "unused" })
final class BinaryLength
extends
AbstractField<Integer>
implements
QOM.BinaryLength
{
final Field<byte[]> bytes;
BinaryLength(
Field<byte[]> bytes
) {
super(
N_BINARY_LENGTH,
allNotNull(INTEGER, bytes)
);
this.bytes = nullSafeNotNull(bytes, VARBINARY);
}
// -------------------------------------------------------------------------
// XXX: QueryPart API
// -------------------------------------------------------------------------
@Override
final boolean parenthesised(Context<?> ctx) {
return true;
}
@Override
public final void accept(Context<?> ctx) {
switch (ctx.family()) {
default:
ctx.visit(function(N_LENGTH, getDataType(), bytes));
break;
}
}
// -------------------------------------------------------------------------
// XXX: Query Object Model
// -------------------------------------------------------------------------
@Override
public final Field<byte[]> $arg1() {
return bytes;
}
@Override
public final QOM.BinaryLength $arg1(Field<byte[]> newValue) {
return $constructor().apply(newValue);
}
@Override
public final Function1<? super Field<byte[]>, ? extends QOM.BinaryLength> $constructor() {
return (a1) -> new BinaryLength(a1);
}
// -------------------------------------------------------------------------
// XXX: The Object API
// -------------------------------------------------------------------------
@Override
public boolean equals(Object that) {
if (that instanceof QOM.BinaryLength o) {
return
StringUtils.equals($bytes(), o.$bytes())
;
}
else
return super.equals(that);
}
}

View File

@ -0,0 +1,156 @@
/*
* 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
*
* https://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: https://www.jooq.org/legal/licensing
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*/
package org.jooq.impl;
import static org.jooq.impl.DSL.*;
import static org.jooq.impl.Internal.*;
import static org.jooq.impl.Keywords.*;
import static org.jooq.impl.Names.*;
import static org.jooq.impl.SQLDataType.*;
import static org.jooq.impl.Tools.*;
import static org.jooq.impl.Tools.BooleanDataKey.*;
import static org.jooq.impl.Tools.ExtendedDataKey.*;
import static org.jooq.impl.Tools.SimpleDataKey.*;
import static org.jooq.SQLDialect.*;
import org.jooq.*;
import org.jooq.Function1;
import org.jooq.Record;
import org.jooq.conf.*;
import org.jooq.impl.*;
import org.jooq.impl.QOM.*;
import org.jooq.tools.*;
import java.util.*;
import java.util.function.*;
import java.util.stream.*;
/**
* The <code>BINARY OCTET LENGTH</code> statement.
*/
@SuppressWarnings({ "rawtypes", "unchecked", "unused" })
final class BinaryOctetLength
extends
AbstractField<Integer>
implements
QOM.BinaryOctetLength
{
final Field<byte[]> bytes;
BinaryOctetLength(
Field<byte[]> bytes
) {
super(
N_BINARY_OCTET_LENGTH,
allNotNull(INTEGER, bytes)
);
this.bytes = nullSafeNotNull(bytes, VARBINARY);
}
// -------------------------------------------------------------------------
// XXX: QueryPart API
// -------------------------------------------------------------------------
@Override
final boolean parenthesised(Context<?> ctx) {
return true;
}
@Override
public final void accept(Context<?> ctx) {
switch (ctx.family()) {
default:
ctx.visit(function(N_OCTET_LENGTH, getDataType(), bytes));
break;
}
}
// -------------------------------------------------------------------------
// XXX: Query Object Model
// -------------------------------------------------------------------------
@Override
public final Field<byte[]> $arg1() {
return bytes;
}
@Override
public final QOM.BinaryOctetLength $arg1(Field<byte[]> newValue) {
return $constructor().apply(newValue);
}
@Override
public final Function1<? super Field<byte[]>, ? extends QOM.BinaryOctetLength> $constructor() {
return (a1) -> new BinaryOctetLength(a1);
}
// -------------------------------------------------------------------------
// XXX: The Object API
// -------------------------------------------------------------------------
@Override
public boolean equals(Object that) {
if (that instanceof QOM.BinaryOctetLength o) {
return
StringUtils.equals($bytes(), o.$bytes())
;
}
else
return super.equals(that);
}
}

View File

@ -0,0 +1,217 @@
/*
* 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
*
* https://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: https://www.jooq.org/legal/licensing
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*/
package org.jooq.impl;
import static org.jooq.impl.DSL.*;
import static org.jooq.impl.Internal.*;
import static org.jooq.impl.Keywords.*;
import static org.jooq.impl.Names.*;
import static org.jooq.impl.SQLDataType.*;
import static org.jooq.impl.Tools.*;
import static org.jooq.impl.Tools.BooleanDataKey.*;
import static org.jooq.impl.Tools.ExtendedDataKey.*;
import static org.jooq.impl.Tools.SimpleDataKey.*;
import static org.jooq.SQLDialect.*;
import org.jooq.*;
import org.jooq.Function1;
import org.jooq.Record;
import org.jooq.conf.*;
import org.jooq.impl.*;
import org.jooq.impl.QOM.*;
import org.jooq.tools.*;
import java.util.*;
import java.util.function.*;
import java.util.stream.*;
/**
* The <code>BINARY OVERLAY</code> statement.
*/
@SuppressWarnings({ "rawtypes", "unchecked", "unused" })
final class BinaryOverlay
extends
AbstractField<byte[]>
implements
QOM.BinaryOverlay
{
final Field<byte[]> in;
final Field<byte[]> placing;
final Field<? extends Number> startIndex;
final Field<? extends Number> length;
BinaryOverlay(
Field<byte[]> in,
Field<byte[]> placing,
Field<? extends Number> startIndex
) {
super(
N_BINARY_OVERLAY,
allNotNull(VARBINARY, in, placing, startIndex)
);
this.in = nullSafeNotNull(in, VARBINARY);
this.placing = nullSafeNotNull(placing, VARBINARY);
this.startIndex = nullSafeNotNull(startIndex, INTEGER);
this.length = null;
}
BinaryOverlay(
Field<byte[]> in,
Field<byte[]> placing,
Field<? extends Number> startIndex,
Field<? extends Number> length
) {
super(
N_BINARY_OVERLAY,
allNotNull(VARBINARY, in, placing, startIndex, length)
);
this.in = nullSafeNotNull(in, VARBINARY);
this.placing = nullSafeNotNull(placing, VARBINARY);
this.startIndex = nullSafeNotNull(startIndex, INTEGER);
this.length = nullSafeNotNull(length, INTEGER);
}
// -------------------------------------------------------------------------
// XXX: QueryPart API
// -------------------------------------------------------------------------
@Override
public final void accept(Context<?> ctx) {
Overlay.accept0(ctx,
in, placing, startIndex, length,
DSL::binaryLength, DSL::binarySubstring, DSL::binarySubstring
);
}
// -------------------------------------------------------------------------
// XXX: Query Object Model
// -------------------------------------------------------------------------
@Override
public final Field<byte[]> $arg1() {
return in;
}
@Override
public final Field<byte[]> $arg2() {
return placing;
}
@Override
public final Field<? extends Number> $arg3() {
return startIndex;
}
@Override
public final Field<? extends Number> $arg4() {
return length;
}
@Override
public final QOM.BinaryOverlay $arg1(Field<byte[]> newValue) {
return $constructor().apply(newValue, $arg2(), $arg3(), $arg4());
}
@Override
public final QOM.BinaryOverlay $arg2(Field<byte[]> newValue) {
return $constructor().apply($arg1(), newValue, $arg3(), $arg4());
}
@Override
public final QOM.BinaryOverlay $arg3(Field<? extends Number> newValue) {
return $constructor().apply($arg1(), $arg2(), newValue, $arg4());
}
@Override
public final QOM.BinaryOverlay $arg4(Field<? extends Number> newValue) {
return $constructor().apply($arg1(), $arg2(), $arg3(), newValue);
}
@Override
public final Function4<? super Field<byte[]>, ? super Field<byte[]>, ? super Field<? extends Number>, ? super Field<? extends Number>, ? extends QOM.BinaryOverlay> $constructor() {
return (a1, a2, a3, a4) -> new BinaryOverlay(a1, a2, a3, a4);
}
// -------------------------------------------------------------------------
// XXX: The Object API
// -------------------------------------------------------------------------
@Override
public boolean equals(Object that) {
if (that instanceof QOM.BinaryOverlay o) {
return
StringUtils.equals($in(), o.$in()) &&
StringUtils.equals($placing(), o.$placing()) &&
StringUtils.equals($startIndex(), o.$startIndex()) &&
StringUtils.equals($length(), o.$length())
;
}
else
return super.equals(that);
}
}

View File

@ -0,0 +1,197 @@
/*
* 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
*
* https://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: https://www.jooq.org/legal/licensing
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*/
package org.jooq.impl;
import static org.jooq.impl.DSL.*;
import static org.jooq.impl.Internal.*;
import static org.jooq.impl.Keywords.*;
import static org.jooq.impl.Names.*;
import static org.jooq.impl.SQLDataType.*;
import static org.jooq.impl.Tools.*;
import static org.jooq.impl.Tools.BooleanDataKey.*;
import static org.jooq.impl.Tools.ExtendedDataKey.*;
import static org.jooq.impl.Tools.SimpleDataKey.*;
import static org.jooq.SQLDialect.*;
import org.jooq.*;
import org.jooq.Function1;
import org.jooq.Record;
import org.jooq.conf.*;
import org.jooq.impl.*;
import org.jooq.impl.QOM.*;
import org.jooq.tools.*;
import java.util.*;
import java.util.function.*;
import java.util.stream.*;
/**
* The <code>BINARY POSITION</code> statement.
*/
@SuppressWarnings({ "rawtypes", "unchecked", "unused" })
final class BinaryPosition
extends
AbstractField<Integer>
implements
QOM.BinaryPosition
{
final Field<byte[]> in;
final Field<byte[]> search;
final Field<? extends Number> startIndex;
BinaryPosition(
Field<byte[]> in,
Field<byte[]> search
) {
super(
N_BINARY_POSITION,
allNotNull(INTEGER, in, search)
);
this.in = nullSafeNotNull(in, VARBINARY);
this.search = nullSafeNotNull(search, VARBINARY);
this.startIndex = null;
}
BinaryPosition(
Field<byte[]> in,
Field<byte[]> search,
Field<? extends Number> startIndex
) {
super(
N_BINARY_POSITION,
allNotNull(INTEGER, in, search, startIndex)
);
this.in = nullSafeNotNull(in, VARBINARY);
this.search = nullSafeNotNull(search, VARBINARY);
this.startIndex = nullSafeNotNull(startIndex, INTEGER);
}
// -------------------------------------------------------------------------
// XXX: QueryPart API
// -------------------------------------------------------------------------
@Override
public final void accept(Context<?> ctx) {
Position.accept0(ctx, in, search, startIndex, DSL::binaryPosition, DSL::binarySubstring);
}
// -------------------------------------------------------------------------
// XXX: Query Object Model
// -------------------------------------------------------------------------
@Override
public final Field<byte[]> $arg1() {
return in;
}
@Override
public final Field<byte[]> $arg2() {
return search;
}
@Override
public final Field<? extends Number> $arg3() {
return startIndex;
}
@Override
public final QOM.BinaryPosition $arg1(Field<byte[]> newValue) {
return $constructor().apply(newValue, $arg2(), $arg3());
}
@Override
public final QOM.BinaryPosition $arg2(Field<byte[]> newValue) {
return $constructor().apply($arg1(), newValue, $arg3());
}
@Override
public final QOM.BinaryPosition $arg3(Field<? extends Number> newValue) {
return $constructor().apply($arg1(), $arg2(), newValue);
}
@Override
public final Function3<? super Field<byte[]>, ? super Field<byte[]>, ? super Field<? extends Number>, ? extends QOM.BinaryPosition> $constructor() {
return (a1, a2, a3) -> new BinaryPosition(a1, a2, a3);
}
// -------------------------------------------------------------------------
// XXX: The Object API
// -------------------------------------------------------------------------
@Override
public boolean equals(Object that) {
if (that instanceof QOM.BinaryPosition o) {
return
StringUtils.equals($in(), o.$in()) &&
StringUtils.equals($search(), o.$search()) &&
StringUtils.equals($startIndex(), o.$startIndex())
;
}
else
return super.equals(that);
}
}

View File

@ -0,0 +1,204 @@
/*
* 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
*
* https://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: https://www.jooq.org/legal/licensing
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*/
package org.jooq.impl;
import static org.jooq.impl.DSL.*;
import static org.jooq.impl.Internal.*;
import static org.jooq.impl.Keywords.*;
import static org.jooq.impl.Names.*;
import static org.jooq.impl.SQLDataType.*;
import static org.jooq.impl.Tools.*;
import static org.jooq.impl.Tools.BooleanDataKey.*;
import static org.jooq.impl.Tools.ExtendedDataKey.*;
import static org.jooq.impl.Tools.SimpleDataKey.*;
import static org.jooq.SQLDialect.*;
import org.jooq.*;
import org.jooq.Function1;
import org.jooq.Record;
import org.jooq.conf.*;
import org.jooq.impl.*;
import org.jooq.impl.QOM.*;
import org.jooq.tools.*;
import java.util.*;
import java.util.function.*;
import java.util.stream.*;
/**
* The <code>BINARY SUBSTRING</code> statement.
*/
@SuppressWarnings({ "rawtypes", "unchecked", "unused" })
final class BinarySubstring
extends
AbstractField<byte[]>
implements
QOM.BinarySubstring
{
final Field<byte[]> string;
final Field<? extends Number> startingPosition;
final Field<? extends Number> length;
BinarySubstring(
Field<byte[]> string,
Field<? extends Number> startingPosition
) {
super(
N_BINARY_SUBSTRING,
allNotNull(VARBINARY, string, startingPosition)
);
this.string = nullSafeNotNull(string, VARBINARY);
this.startingPosition = nullSafeNotNull(startingPosition, INTEGER);
this.length = null;
}
BinarySubstring(
Field<byte[]> string,
Field<? extends Number> startingPosition,
Field<? extends Number> length
) {
super(
N_BINARY_SUBSTRING,
allNotNull(VARBINARY, string, startingPosition, length)
);
this.string = nullSafeNotNull(string, VARBINARY);
this.startingPosition = nullSafeNotNull(startingPosition, INTEGER);
this.length = nullSafeNotNull(length, INTEGER);
}
// -------------------------------------------------------------------------
// XXX: QueryPart API
// -------------------------------------------------------------------------
@Override
final boolean parenthesised(Context<?> ctx) {
return true;
}
@Override
public final void accept(Context<?> ctx) {
switch (ctx.family()) {
default:
if (length != null)
ctx.visit(function(N_SUBSTRING, getDataType(), string, startingPosition, length));
else
ctx.visit(function(N_SUBSTRING, getDataType(), string, startingPosition));
break;
}
}
// -------------------------------------------------------------------------
// XXX: Query Object Model
// -------------------------------------------------------------------------
@Override
public final Field<byte[]> $arg1() {
return string;
}
@Override
public final Field<? extends Number> $arg2() {
return startingPosition;
}
@Override
public final Field<? extends Number> $arg3() {
return length;
}
@Override
public final QOM.BinarySubstring $arg1(Field<byte[]> newValue) {
return $constructor().apply(newValue, $arg2(), $arg3());
}
@Override
public final QOM.BinarySubstring $arg2(Field<? extends Number> newValue) {
return $constructor().apply($arg1(), newValue, $arg3());
}
@Override
public final QOM.BinarySubstring $arg3(Field<? extends Number> newValue) {
return $constructor().apply($arg1(), $arg2(), newValue);
}
@Override
public final Function3<? super Field<byte[]>, ? super Field<? extends Number>, ? super Field<? extends Number>, ? extends QOM.BinarySubstring> $constructor() {
return (a1, a2, a3) -> new BinarySubstring(a1, a2, a3);
}
// -------------------------------------------------------------------------
// XXX: The Object API
// -------------------------------------------------------------------------
@Override
public boolean equals(Object that) {
if (that instanceof QOM.BinarySubstring o) {
return
StringUtils.equals($string(), o.$string()) &&
StringUtils.equals($startingPosition(), o.$startingPosition()) &&
StringUtils.equals($length(), o.$length())
;
}
else
return super.equals(that);
}
}

View File

@ -20900,6 +20900,28 @@ public class DSL {
// Binary functions
// -------------------------------------------------------------------------
/**
* The <code>BINARY_BIT_LENGTH</code> function.
* <p>
* The length of a binary string in bits.
*/
@NotNull
@Support({ POSTGRES, YUGABYTEDB })
public static Field<Integer> binaryBitLength(byte[] bytes) {
return new BinaryBitLength(Tools.field(bytes));
}
/**
* The <code>BINARY_BIT_LENGTH</code> function.
* <p>
* The length of a binary string in bits.
*/
@NotNull
@Support({ POSTGRES, YUGABYTEDB })
public static Field<Integer> binaryBitLength(Field<byte[]> bytes) {
return new BinaryBitLength(bytes);
}
/**
* The <code>BINARY_LENGTH</code> function.
* <p>
@ -21000,6 +21022,28 @@ public class DSL {
return new BinaryMd5(bytes);
}
/**
* The <code>BINARY_OCTET_LENGTH</code> function.
* <p>
* The length of a binary string in octets.
*/
@NotNull
@Support
public static Field<Integer> binaryOctetLength(byte[] bytes) {
return new BinaryOctetLength(Tools.field(bytes));
}
/**
* The <code>BINARY_OCTET_LENGTH</code> function.
* <p>
* The length of a binary string in octets.
*/
@NotNull
@Support
public static Field<Integer> binaryOctetLength(Field<byte[]> bytes) {
return new BinaryOctetLength(bytes);
}
/**
* The <code>BINARY_OVERLAY</code> function.
* <p>
@ -21072,7 +21116,7 @@ public class DSL {
* @param startIndex The start index (1-based) from which to start looking for the substring.
*/
@NotNull
@Support
@Support({ POSTGRES, YUGABYTEDB })
public static Field<Integer> binaryPosition(byte[] in, byte[] search, int startIndex) {
return new BinaryPosition(Tools.field(in), Tools.field(search), Tools.field(startIndex));
}
@ -21087,7 +21131,7 @@ public class DSL {
* @param startIndex The start index (1-based) from which to start looking for the substring.
*/
@NotNull
@Support
@Support({ POSTGRES, YUGABYTEDB })
public static Field<Integer> binaryPosition(byte[] in, byte[] search, Field<? extends Number> startIndex) {
return new BinaryPosition(Tools.field(in), Tools.field(search), startIndex);
}
@ -21102,7 +21146,7 @@ public class DSL {
* @param startIndex The start index (1-based) from which to start looking for the substring.
*/
@NotNull
@Support
@Support({ POSTGRES, YUGABYTEDB })
public static Field<Integer> binaryPosition(byte[] in, Field<byte[]> search, int startIndex) {
return new BinaryPosition(Tools.field(in), search, Tools.field(startIndex));
}
@ -21117,7 +21161,7 @@ public class DSL {
* @param startIndex The start index (1-based) from which to start looking for the substring.
*/
@NotNull
@Support
@Support({ POSTGRES, YUGABYTEDB })
public static Field<Integer> binaryPosition(byte[] in, Field<byte[]> search, Field<? extends Number> startIndex) {
return new BinaryPosition(Tools.field(in), search, startIndex);
}
@ -21132,7 +21176,7 @@ public class DSL {
* @param startIndex The start index (1-based) from which to start looking for the substring.
*/
@NotNull
@Support
@Support({ POSTGRES, YUGABYTEDB })
public static Field<Integer> binaryPosition(Field<byte[]> in, byte[] search, int startIndex) {
return new BinaryPosition(in, Tools.field(search), Tools.field(startIndex));
}
@ -21147,7 +21191,7 @@ public class DSL {
* @param startIndex The start index (1-based) from which to start looking for the substring.
*/
@NotNull
@Support
@Support({ POSTGRES, YUGABYTEDB })
public static Field<Integer> binaryPosition(Field<byte[]> in, byte[] search, Field<? extends Number> startIndex) {
return new BinaryPosition(in, Tools.field(search), startIndex);
}
@ -21162,7 +21206,7 @@ public class DSL {
* @param startIndex The start index (1-based) from which to start looking for the substring.
*/
@NotNull
@Support
@Support({ POSTGRES, YUGABYTEDB })
public static Field<Integer> binaryPosition(Field<byte[]> in, Field<byte[]> search, int startIndex) {
return new BinaryPosition(in, search, Tools.field(startIndex));
}
@ -21177,7 +21221,7 @@ public class DSL {
* @param startIndex The start index (1-based) from which to start looking for the substring.
*/
@NotNull
@Support
@Support({ POSTGRES, YUGABYTEDB })
public static Field<Integer> binaryPosition(Field<byte[]> in, Field<byte[]> search, Field<? extends Number> startIndex) {
return new BinaryPosition(in, search, startIndex);
}
@ -21191,7 +21235,7 @@ public class DSL {
* @param search The substring to search for.
*/
@NotNull
@Support
@Support({ POSTGRES, YUGABYTEDB })
public static Field<Integer> binaryPosition(byte[] in, byte[] search) {
return new BinaryPosition(Tools.field(in), Tools.field(search));
}
@ -21205,7 +21249,7 @@ public class DSL {
* @param search The substring to search for.
*/
@NotNull
@Support
@Support({ POSTGRES, YUGABYTEDB })
public static Field<Integer> binaryPosition(byte[] in, Field<byte[]> search) {
return new BinaryPosition(Tools.field(in), search);
}
@ -21219,7 +21263,7 @@ public class DSL {
* @param search The substring to search for.
*/
@NotNull
@Support
@Support({ POSTGRES, YUGABYTEDB })
public static Field<Integer> binaryPosition(Field<byte[]> in, byte[] search) {
return new BinaryPosition(in, Tools.field(search));
}
@ -21233,7 +21277,7 @@ public class DSL {
* @param search The substring to search for.
*/
@NotNull
@Support
@Support({ POSTGRES, YUGABYTEDB })
public static Field<Integer> binaryPosition(Field<byte[]> in, Field<byte[]> search) {
return new BinaryPosition(in, search);
}

View File

@ -330,9 +330,11 @@ final class Names {
static final Name N_ATN = systemName("atn");
static final Name N_ATN2 = systemName("atn2");
static final Name N_AVG = systemName("avg");
static final Name N_BINARY_BIT_LENGTH = systemName("binary_bit_length");
static final Name N_BINARY_LENGTH = systemName("binary_length");
static final Name N_BINARY_LTRIM = systemName("binary_ltrim");
static final Name N_BINARY_MD5 = systemName("binary_md5");
static final Name N_BINARY_OCTET_LENGTH = systemName("binary_octet_length");
static final Name N_BINARY_OVERLAY = systemName("binary_overlay");
static final Name N_BINARY_POSITION = systemName("binary_position");
static final Name N_BINARY_RTRIM = systemName("binary_rtrim");

View File

@ -98,6 +98,7 @@ import static org.jooq.impl.DSL.begin;
import static org.jooq.impl.DSL.binaryLength;
import static org.jooq.impl.DSL.binaryLtrim;
import static org.jooq.impl.DSL.binaryMd5;
import static org.jooq.impl.DSL.binaryOctetLength;
import static org.jooq.impl.DSL.binaryOverlay;
import static org.jooq.impl.DSL.binaryRtrim;
import static org.jooq.impl.DSL.binarySubstring;
@ -8667,7 +8668,7 @@ final class DefaultParseContext extends AbstractScope implements ParseContext {
case 'B':
if (parseFunctionNameIf("BIT_LENGTH"))
return bitLength((Field) parseFieldParenthesised());
return parseFunctionArgs1(binary1(DSL::binaryBitLength, DSL::bitLength));
else if (parseFunctionNameIf("BITGET", "BIT_GET"))
return parseFunctionArgs2(DSL::bitGet);
else if (parseFunctionNameIf("BITSET", "BIT_SET"))
@ -8704,7 +8705,7 @@ final class DefaultParseContext extends AbstractScope implements ParseContext {
else if (parseFunctionNameIf("CHARINDEX"))
return parseFunctionArgs3(
(f1, f2) -> binary(f1, f2) ? DSL.binaryPosition(f2, f1) : DSL.position(f2, f1),
binary2(DSL::binaryPosition, DSL::position),
(f1, f2, f3) -> binary(f1, f2) ? DSL.binaryPosition(f2, f1, f3) : DSL.position(f2, f1, f3)
);
else if (parseFunctionNameIf("CHAR_LENGTH"))
@ -8909,7 +8910,7 @@ final class DefaultParseContext extends AbstractScope implements ParseContext {
return hour(parseFieldParenthesised());
else if (parseFunctionNameIf("HASH_MD5"))
return parseFunctionArgs1(f -> f.getDataType().isBinary() ? binaryMd5(f) : md5(f));
return parseFunctionArgs1(binary1(DSL::binaryMd5, DSL::md5));
else if (parseFunctionNameIf("HEX"))
return toHex((Field) parseFieldParenthesised());
@ -8924,7 +8925,7 @@ final class DefaultParseContext extends AbstractScope implements ParseContext {
return isoDayOfWeek(parseFieldParenthesised());
else if (parseFunctionNameIf("INSTR"))
return parseFunctionArgs3(
(f1, f2) -> binary(f1, f2) ? DSL.binaryPosition(f1, f2) : DSL.position(f1, f2),
binary2(DSL::binaryPosition, DSL::position),
(f1, f2, f3) -> binary(f1, f2) ? DSL.binaryPosition(f1, f2, f3) : DSL.position(f1, f2, f3)
);
else if (parseFunctionNameIf("INSERT"))
@ -8980,11 +8981,11 @@ final class DefaultParseContext extends AbstractScope implements ParseContext {
else if (parseFunctionNameIf("LPAD"))
return parseFunctionArgs3(DSL::lpad, DSL::lpad);
else if (parseFunctionNameIf("LTRIM"))
return parseFunctionArgs2(DSL::ltrim, (f1, f2) -> binary(f1, f2) ? binaryLtrim(f1, f2) : ltrim(f1, f2));
return parseFunctionArgs2(DSL::ltrim, binary2(DSL::binaryLtrim, DSL::ltrim));
else if (parseFunctionNameIf("LEFT"))
return parseFunctionArgs2(DSL::left);
else if (parseFunctionNameIf("LENGTH", "LEN"))
return parseFunctionArgs1(f -> f.getDataType().isBinary() ? binaryLength(f) : length(f));
return parseFunctionArgs1(binary1(DSL::binaryLength, DSL::length));
else if (parseFunctionNameIf("LENGTHB"))
return octetLength((Field) parseFieldParenthesised());
else if (parseFunctionNameIf("LN", "LOGN"))
@ -9027,7 +9028,7 @@ final class DefaultParseContext extends AbstractScope implements ParseContext {
else if (parseFunctionNameIf("MID"))
return parseFunctionArgs3(DSL::mid);
else if (parseFunctionNameIf("MD5"))
return parseFunctionArgs1(f -> f.getDataType().isBinary() ? binaryMd5(f) : md5(f));
return parseFunctionArgs1(binary1(DSL::binaryMd5, DSL::md5));
else if ((field = parseMultisetValueConstructorIf()) != null)
return field;
@ -9087,7 +9088,7 @@ final class DefaultParseContext extends AbstractScope implements ParseContext {
else if ((field = parseFieldTranslateIf()) != null)
return field;
else if (parseFunctionNameIf("OCTET_LENGTH"))
return octetLength((Field) parseFieldParenthesised());
return parseFunctionArgs1(binary1(DSL::binaryOctetLength, DSL::octetLength));
else if ((field = parseFieldObjectConstructIf()) != null)
return field;
else if (parseFunctionNameIf("OBJECT_KEYS"))
@ -9137,7 +9138,7 @@ final class DefaultParseContext extends AbstractScope implements ParseContext {
else if (parseFunctionNameIf("RPAD"))
return parseFunctionArgs3(DSL::rpad, DSL::rpad);
else if (parseFunctionNameIf("RTRIM"))
return parseFunctionArgs2(DSL::rtrim, (f1, f2) -> binary(f1, f2) ? binaryRtrim(f1, f2) : rtrim(f1, f2));
return parseFunctionArgs2(DSL::rtrim, binary2(DSL::binaryRtrim, DSL::rtrim));
else if (parseFunctionNameIf("RIGHT"))
return parseFunctionArgs2(DSL::right);
else if (parseFunctionNameIf("RANDOM_UUID") && parseEmptyParens())
@ -11376,10 +11377,28 @@ final class DefaultParseContext extends AbstractScope implements ParseContext {
return null;
}
private final boolean binary(Field<?> f1) {
return f1.getDataType().isBinary();
}
private final boolean binary(Field<?> f1, Field<?> f2) {
return f1.getDataType().isBinary() || f2.getDataType().isBinary();
}
private final <Q> Function1<? super Field<?>, ? extends Q> binary1(
Function1<? super Field, ? extends Q> binary,
Function1<? super Field, ? extends Q> nonBinary
) {
return f1 -> binary(f1) ? binary.apply(f1) : nonBinary.apply(f1);
}
private final <Q> Function2<? super Field<?>, ? super Field<?>, ? extends Q> binary2(
Function2<? super Field, ? super Field, ? extends Q> binary,
Function2<? super Field, ? super Field, ? extends Q> nonBinary
) {
return (f1, f2) -> binary(f1, f2) ? binary.apply(f1, f2) : nonBinary.apply(f1, f2);
}
private final Field<?> parseFieldPositionIf() {
if (parseFunctionNameIf("POSITION")) {
parse('(');
@ -11534,7 +11553,6 @@ final class DefaultParseContext extends AbstractScope implements ParseContext {
boolean keywords = !substr;
parse('(');
Field f1 = parseField();
boolean binary = f1.getDataType().isBinary();
if (substr || !(keywords = parseKeywordIf("FROM")))
parse(',');
Field f2 = toField(parseNumericOp());
@ -11545,10 +11563,10 @@ final class DefaultParseContext extends AbstractScope implements ParseContext {
parse(')');
return f3 == null
? binary
? binary(f1)
? DSL.binarySubstring(f1, f2)
: DSL.substring(f1, f2)
: binary
: binary(f1)
? DSL.binarySubstring(f1, f2, f3)
: DSL.substring(f1, f2, f3);
}

View File

@ -5826,6 +5826,24 @@ public final class QOM {
// Uuid
{}
/**
* The <code>BINARY BIT LENGTH</code> function.
* <p>
* The length of a binary string in bits.
*/
public /*sealed*/ interface BinaryBitLength
extends
UReturnsNullOnNullInput,
UOperator1<Field<byte[]>, BinaryBitLength>,
org.jooq.Field<Integer>
//permits
// BinaryBitLength
{
@NotNull default Field<byte[]> $bytes() { return $arg1(); }
@CheckReturnValue
@NotNull default BinaryBitLength $bytes(Field<byte[]> newBytes) { return $arg1(newBytes); }
}
/**
* The <code>BINARY LENGTH</code> function.
* <p>
@ -5899,6 +5917,24 @@ public final class QOM {
@NotNull default BinaryMd5 $bytes(Field<byte[]> newBytes) { return $arg1(newBytes); }
}
/**
* The <code>BINARY OCTET LENGTH</code> function.
* <p>
* The length of a binary string in octets.
*/
public /*sealed*/ interface BinaryOctetLength
extends
UReturnsNullOnNullInput,
UOperator1<Field<byte[]>, BinaryOctetLength>,
org.jooq.Field<Integer>
//permits
// BinaryOctetLength
{
@NotNull default Field<byte[]> $bytes() { return $arg1(); }
@CheckReturnValue
@NotNull default BinaryOctetLength $bytes(Field<byte[]> newBytes) { return $arg1(newBytes); }
}
/**
* The <code>BINARY OVERLAY</code> function.
* <p>