ROWNUM transformation doesn't work when projecting an expression containing ROWNUM. This fix also refactors arithmetic Expressions to their own classes, including internal IAdd, ISub, IMul, IDiv for the unneeded arithmetic transformation (further refactorings scheduled)
This commit is contained in:
parent
d5a586c767
commit
3f0e0cf7a7
176
jOOQ/src/main/java/org/jooq/impl/Add.java
Normal file
176
jOOQ/src/main/java/org/jooq/impl/Add.java
Normal file
@ -0,0 +1,176 @@
|
||||
/*
|
||||
* 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.*;
|
||||
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.DataExtendedKey.*;
|
||||
import static org.jooq.impl.Tools.DataKey.*;
|
||||
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>ADD</code> statement.
|
||||
*/
|
||||
@SuppressWarnings({ "rawtypes", "unchecked", "unused" })
|
||||
final class Add<T>
|
||||
extends
|
||||
AbstractTransformable<T>
|
||||
implements
|
||||
QOM.Add<T>
|
||||
{
|
||||
|
||||
final Field<T> arg1;
|
||||
final Field<T> arg2;
|
||||
|
||||
Add(
|
||||
Field<T> arg1,
|
||||
Field<T> arg2
|
||||
) {
|
||||
super(
|
||||
N_ADD,
|
||||
allNotNull((DataType) dataType(arg1), arg1, arg2)
|
||||
);
|
||||
|
||||
this.arg1 = nullSafeNotNull(arg1, (DataType) OTHER);
|
||||
this.arg2 = nullSafeNotNull(arg2, (DataType) OTHER);
|
||||
}
|
||||
|
||||
// -------------------------------------------------------------------------
|
||||
// XXX: QueryPart API
|
||||
// -------------------------------------------------------------------------
|
||||
|
||||
|
||||
|
||||
@Override
|
||||
public final void accept0(Context<?> ctx) {
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
ctx.sql('(');
|
||||
Expression.<Field<T>, Add<T>>acceptAssociative(
|
||||
ctx,
|
||||
this,
|
||||
q -> new Expression.Expr<>(q.arg1, Operators.OP_PLUS, q.arg2),
|
||||
c -> c.sql(' ')
|
||||
);
|
||||
ctx.sql(')');
|
||||
}
|
||||
|
||||
@Override
|
||||
public final Field<?> transform(TransformUnneededArithmeticExpressions transform) {
|
||||
return Expression.transform(this, arg1, ExpressionOperator.ADD, arg2, false, transform);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
// -------------------------------------------------------------------------
|
||||
// XXX: Query Object Model
|
||||
// -------------------------------------------------------------------------
|
||||
|
||||
@Override
|
||||
public final Field<T> $arg1() {
|
||||
return arg1;
|
||||
}
|
||||
|
||||
@Override
|
||||
public final Field<T> $arg2() {
|
||||
return arg2;
|
||||
}
|
||||
|
||||
@Override
|
||||
public final QOM.Add<T> $arg1(Field<T> newValue) {
|
||||
return constructor().apply(newValue, $arg2());
|
||||
}
|
||||
|
||||
@Override
|
||||
public final QOM.Add<T> $arg2(Field<T> newValue) {
|
||||
return constructor().apply($arg1(), newValue);
|
||||
}
|
||||
|
||||
@Override
|
||||
public final Function2<? super Field<T>, ? super Field<T>, ? extends QOM.Add<T>> constructor() {
|
||||
return (a1, a2) -> new Add<>(a1, a2);
|
||||
}
|
||||
|
||||
// -------------------------------------------------------------------------
|
||||
// XXX: The Object API
|
||||
// -------------------------------------------------------------------------
|
||||
|
||||
@Override
|
||||
public boolean equals(Object that) {
|
||||
if (that instanceof Add) { Add o = (Add) that;
|
||||
return
|
||||
StringUtils.equals($arg1(), o.$arg1()) &&
|
||||
StringUtils.equals($arg2(), o.$arg2())
|
||||
;
|
||||
}
|
||||
else
|
||||
return super.equals(that);
|
||||
}
|
||||
}
|
||||
169
jOOQ/src/main/java/org/jooq/impl/Div.java
Normal file
169
jOOQ/src/main/java/org/jooq/impl/Div.java
Normal file
@ -0,0 +1,169 @@
|
||||
/*
|
||||
* 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.*;
|
||||
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.DataExtendedKey.*;
|
||||
import static org.jooq.impl.Tools.DataKey.*;
|
||||
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>DIV</code> statement.
|
||||
*/
|
||||
@SuppressWarnings({ "rawtypes", "unchecked", "unused" })
|
||||
final class Div<T>
|
||||
extends
|
||||
AbstractTransformable<T>
|
||||
implements
|
||||
QOM.Div<T>
|
||||
{
|
||||
|
||||
final Field<T> arg1;
|
||||
final Field<T> arg2;
|
||||
|
||||
Div(
|
||||
Field<T> arg1,
|
||||
Field<T> arg2
|
||||
) {
|
||||
super(
|
||||
N_DIV,
|
||||
allNotNull((DataType) dataType(arg1), arg1, arg2)
|
||||
);
|
||||
|
||||
this.arg1 = nullSafeNotNull(arg1, (DataType) OTHER);
|
||||
this.arg2 = nullSafeNotNull(arg2, (DataType) OTHER);
|
||||
}
|
||||
|
||||
// -------------------------------------------------------------------------
|
||||
// XXX: QueryPart API
|
||||
// -------------------------------------------------------------------------
|
||||
|
||||
|
||||
|
||||
@Override
|
||||
public final void accept0(Context<?> ctx) {
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
ctx.sql('(').visit(arg1).sql(" / ").visit(arg2).sql(')');
|
||||
}
|
||||
|
||||
@Override
|
||||
public final Field<?> transform(TransformUnneededArithmeticExpressions transform) {
|
||||
return Expression.transform(this, arg1, ExpressionOperator.DIVIDE, arg2, false, transform);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
// -------------------------------------------------------------------------
|
||||
// XXX: Query Object Model
|
||||
// -------------------------------------------------------------------------
|
||||
|
||||
@Override
|
||||
public final Field<T> $arg1() {
|
||||
return arg1;
|
||||
}
|
||||
|
||||
@Override
|
||||
public final Field<T> $arg2() {
|
||||
return arg2;
|
||||
}
|
||||
|
||||
@Override
|
||||
public final QOM.Div<T> $arg1(Field<T> newValue) {
|
||||
return constructor().apply(newValue, $arg2());
|
||||
}
|
||||
|
||||
@Override
|
||||
public final QOM.Div<T> $arg2(Field<T> newValue) {
|
||||
return constructor().apply($arg1(), newValue);
|
||||
}
|
||||
|
||||
@Override
|
||||
public final Function2<? super Field<T>, ? super Field<T>, ? extends QOM.Div<T>> constructor() {
|
||||
return (a1, a2) -> new Div<>(a1, a2);
|
||||
}
|
||||
|
||||
// -------------------------------------------------------------------------
|
||||
// XXX: The Object API
|
||||
// -------------------------------------------------------------------------
|
||||
|
||||
@Override
|
||||
public boolean equals(Object that) {
|
||||
if (that instanceof Div) { Div o = (Div) that;
|
||||
return
|
||||
StringUtils.equals($arg1(), o.$arg1()) &&
|
||||
StringUtils.equals($arg2(), o.$arg2())
|
||||
;
|
||||
}
|
||||
else
|
||||
return super.equals(that);
|
||||
}
|
||||
}
|
||||
153
jOOQ/src/main/java/org/jooq/impl/IAdd.java
Normal file
153
jOOQ/src/main/java/org/jooq/impl/IAdd.java
Normal file
@ -0,0 +1,153 @@
|
||||
/*
|
||||
* 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.*;
|
||||
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.DataExtendedKey.*;
|
||||
import static org.jooq.impl.Tools.DataKey.*;
|
||||
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>ADD</code> statement.
|
||||
*/
|
||||
@SuppressWarnings({ "rawtypes", "unchecked", "unused" })
|
||||
final class IAdd<T>
|
||||
extends
|
||||
AbstractTransformable<T>
|
||||
implements
|
||||
QOM.Add<T>
|
||||
{
|
||||
|
||||
final Field<T> arg1;
|
||||
final Field<T> arg2;
|
||||
|
||||
IAdd(
|
||||
Field<T> arg1,
|
||||
Field<T> arg2
|
||||
) {
|
||||
super(
|
||||
N_ADD,
|
||||
allNotNull((DataType) dataType(arg1), arg1, arg2)
|
||||
);
|
||||
|
||||
this.arg1 = nullSafeNotNull(arg1, (DataType) OTHER);
|
||||
this.arg2 = nullSafeNotNull(arg2, (DataType) OTHER);
|
||||
}
|
||||
|
||||
// -------------------------------------------------------------------------
|
||||
// XXX: QueryPart API
|
||||
// -------------------------------------------------------------------------
|
||||
|
||||
@Override
|
||||
public final void accept0(Context<?> ctx) {
|
||||
ctx.visit(transform(Add::new));
|
||||
}
|
||||
|
||||
|
||||
|
||||
@Override
|
||||
public final Field<?> transform(TransformUnneededArithmeticExpressions transform) {
|
||||
return Expression.transform(this, arg1, ExpressionOperator.ADD, arg2, true, transform);
|
||||
}
|
||||
|
||||
|
||||
|
||||
// -------------------------------------------------------------------------
|
||||
// XXX: Query Object Model
|
||||
// -------------------------------------------------------------------------
|
||||
|
||||
@Override
|
||||
public final Field<T> $arg1() {
|
||||
return arg1;
|
||||
}
|
||||
|
||||
@Override
|
||||
public final Field<T> $arg2() {
|
||||
return arg2;
|
||||
}
|
||||
|
||||
@Override
|
||||
public final QOM.Add<T> $arg1(Field<T> newValue) {
|
||||
return constructor().apply(newValue, $arg2());
|
||||
}
|
||||
|
||||
@Override
|
||||
public final QOM.Add<T> $arg2(Field<T> newValue) {
|
||||
return constructor().apply($arg1(), newValue);
|
||||
}
|
||||
|
||||
@Override
|
||||
public final Function2<? super Field<T>, ? super Field<T>, ? extends QOM.Add<T>> constructor() {
|
||||
return (a1, a2) -> new IAdd<>(a1, a2);
|
||||
}
|
||||
|
||||
// -------------------------------------------------------------------------
|
||||
// XXX: The Object API
|
||||
// -------------------------------------------------------------------------
|
||||
|
||||
@Override
|
||||
public boolean equals(Object that) {
|
||||
if (that instanceof IAdd) { IAdd o = (IAdd) that;
|
||||
return
|
||||
StringUtils.equals($arg1(), o.$arg1()) &&
|
||||
StringUtils.equals($arg2(), o.$arg2())
|
||||
;
|
||||
}
|
||||
else
|
||||
return super.equals(that);
|
||||
}
|
||||
}
|
||||
153
jOOQ/src/main/java/org/jooq/impl/IDiv.java
Normal file
153
jOOQ/src/main/java/org/jooq/impl/IDiv.java
Normal file
@ -0,0 +1,153 @@
|
||||
/*
|
||||
* 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.*;
|
||||
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.DataExtendedKey.*;
|
||||
import static org.jooq.impl.Tools.DataKey.*;
|
||||
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>DIV</code> statement.
|
||||
*/
|
||||
@SuppressWarnings({ "rawtypes", "unchecked", "unused" })
|
||||
final class IDiv<T>
|
||||
extends
|
||||
AbstractTransformable<T>
|
||||
implements
|
||||
QOM.Div<T>
|
||||
{
|
||||
|
||||
final Field<T> arg1;
|
||||
final Field<T> arg2;
|
||||
|
||||
IDiv(
|
||||
Field<T> arg1,
|
||||
Field<T> arg2
|
||||
) {
|
||||
super(
|
||||
N_DIV,
|
||||
allNotNull((DataType) dataType(arg1), arg1, arg2)
|
||||
);
|
||||
|
||||
this.arg1 = nullSafeNotNull(arg1, (DataType) OTHER);
|
||||
this.arg2 = nullSafeNotNull(arg2, (DataType) OTHER);
|
||||
}
|
||||
|
||||
// -------------------------------------------------------------------------
|
||||
// XXX: QueryPart API
|
||||
// -------------------------------------------------------------------------
|
||||
|
||||
@Override
|
||||
public final void accept0(Context<?> ctx) {
|
||||
ctx.visit(transform(Div::new));
|
||||
}
|
||||
|
||||
|
||||
|
||||
@Override
|
||||
public final Field<?> transform(TransformUnneededArithmeticExpressions transform) {
|
||||
return Expression.transform(this, arg1, ExpressionOperator.DIVIDE, arg2, true, transform);
|
||||
}
|
||||
|
||||
|
||||
|
||||
// -------------------------------------------------------------------------
|
||||
// XXX: Query Object Model
|
||||
// -------------------------------------------------------------------------
|
||||
|
||||
@Override
|
||||
public final Field<T> $arg1() {
|
||||
return arg1;
|
||||
}
|
||||
|
||||
@Override
|
||||
public final Field<T> $arg2() {
|
||||
return arg2;
|
||||
}
|
||||
|
||||
@Override
|
||||
public final QOM.Div<T> $arg1(Field<T> newValue) {
|
||||
return constructor().apply(newValue, $arg2());
|
||||
}
|
||||
|
||||
@Override
|
||||
public final QOM.Div<T> $arg2(Field<T> newValue) {
|
||||
return constructor().apply($arg1(), newValue);
|
||||
}
|
||||
|
||||
@Override
|
||||
public final Function2<? super Field<T>, ? super Field<T>, ? extends QOM.Div<T>> constructor() {
|
||||
return (a1, a2) -> new IDiv<>(a1, a2);
|
||||
}
|
||||
|
||||
// -------------------------------------------------------------------------
|
||||
// XXX: The Object API
|
||||
// -------------------------------------------------------------------------
|
||||
|
||||
@Override
|
||||
public boolean equals(Object that) {
|
||||
if (that instanceof IDiv) { IDiv o = (IDiv) that;
|
||||
return
|
||||
StringUtils.equals($arg1(), o.$arg1()) &&
|
||||
StringUtils.equals($arg2(), o.$arg2())
|
||||
;
|
||||
}
|
||||
else
|
||||
return super.equals(that);
|
||||
}
|
||||
}
|
||||
153
jOOQ/src/main/java/org/jooq/impl/IMul.java
Normal file
153
jOOQ/src/main/java/org/jooq/impl/IMul.java
Normal file
@ -0,0 +1,153 @@
|
||||
/*
|
||||
* 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.*;
|
||||
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.DataExtendedKey.*;
|
||||
import static org.jooq.impl.Tools.DataKey.*;
|
||||
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>MUL</code> statement.
|
||||
*/
|
||||
@SuppressWarnings({ "rawtypes", "unchecked", "unused" })
|
||||
final class IMul<T>
|
||||
extends
|
||||
AbstractTransformable<T>
|
||||
implements
|
||||
QOM.Mul<T>
|
||||
{
|
||||
|
||||
final Field<T> arg1;
|
||||
final Field<T> arg2;
|
||||
|
||||
IMul(
|
||||
Field<T> arg1,
|
||||
Field<T> arg2
|
||||
) {
|
||||
super(
|
||||
N_MUL,
|
||||
allNotNull((DataType) dataType(arg1), arg1, arg2)
|
||||
);
|
||||
|
||||
this.arg1 = nullSafeNotNull(arg1, (DataType) OTHER);
|
||||
this.arg2 = nullSafeNotNull(arg2, (DataType) OTHER);
|
||||
}
|
||||
|
||||
// -------------------------------------------------------------------------
|
||||
// XXX: QueryPart API
|
||||
// -------------------------------------------------------------------------
|
||||
|
||||
@Override
|
||||
public final void accept0(Context<?> ctx) {
|
||||
ctx.visit(transform(Mul::new));
|
||||
}
|
||||
|
||||
|
||||
|
||||
@Override
|
||||
public final Field<?> transform(TransformUnneededArithmeticExpressions transform) {
|
||||
return Expression.transform(this, arg1, ExpressionOperator.MULTIPLY, arg2, true, transform);
|
||||
}
|
||||
|
||||
|
||||
|
||||
// -------------------------------------------------------------------------
|
||||
// XXX: Query Object Model
|
||||
// -------------------------------------------------------------------------
|
||||
|
||||
@Override
|
||||
public final Field<T> $arg1() {
|
||||
return arg1;
|
||||
}
|
||||
|
||||
@Override
|
||||
public final Field<T> $arg2() {
|
||||
return arg2;
|
||||
}
|
||||
|
||||
@Override
|
||||
public final QOM.Mul<T> $arg1(Field<T> newValue) {
|
||||
return constructor().apply(newValue, $arg2());
|
||||
}
|
||||
|
||||
@Override
|
||||
public final QOM.Mul<T> $arg2(Field<T> newValue) {
|
||||
return constructor().apply($arg1(), newValue);
|
||||
}
|
||||
|
||||
@Override
|
||||
public final Function2<? super Field<T>, ? super Field<T>, ? extends QOM.Mul<T>> constructor() {
|
||||
return (a1, a2) -> new IMul<>(a1, a2);
|
||||
}
|
||||
|
||||
// -------------------------------------------------------------------------
|
||||
// XXX: The Object API
|
||||
// -------------------------------------------------------------------------
|
||||
|
||||
@Override
|
||||
public boolean equals(Object that) {
|
||||
if (that instanceof IMul) { IMul o = (IMul) that;
|
||||
return
|
||||
StringUtils.equals($arg1(), o.$arg1()) &&
|
||||
StringUtils.equals($arg2(), o.$arg2())
|
||||
;
|
||||
}
|
||||
else
|
||||
return super.equals(that);
|
||||
}
|
||||
}
|
||||
153
jOOQ/src/main/java/org/jooq/impl/ISub.java
Normal file
153
jOOQ/src/main/java/org/jooq/impl/ISub.java
Normal file
@ -0,0 +1,153 @@
|
||||
/*
|
||||
* 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.*;
|
||||
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.DataExtendedKey.*;
|
||||
import static org.jooq.impl.Tools.DataKey.*;
|
||||
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>SUB</code> statement.
|
||||
*/
|
||||
@SuppressWarnings({ "rawtypes", "unchecked", "unused" })
|
||||
final class ISub<T>
|
||||
extends
|
||||
AbstractTransformable<T>
|
||||
implements
|
||||
QOM.Sub<T>
|
||||
{
|
||||
|
||||
final Field<T> arg1;
|
||||
final Field<T> arg2;
|
||||
|
||||
ISub(
|
||||
Field<T> arg1,
|
||||
Field<T> arg2
|
||||
) {
|
||||
super(
|
||||
N_SUB,
|
||||
allNotNull((DataType) dataType(arg1), arg1, arg2)
|
||||
);
|
||||
|
||||
this.arg1 = nullSafeNotNull(arg1, (DataType) OTHER);
|
||||
this.arg2 = nullSafeNotNull(arg2, (DataType) OTHER);
|
||||
}
|
||||
|
||||
// -------------------------------------------------------------------------
|
||||
// XXX: QueryPart API
|
||||
// -------------------------------------------------------------------------
|
||||
|
||||
@Override
|
||||
public final void accept0(Context<?> ctx) {
|
||||
ctx.visit(transform(Sub::new));
|
||||
}
|
||||
|
||||
|
||||
|
||||
@Override
|
||||
public final Field<?> transform(TransformUnneededArithmeticExpressions transform) {
|
||||
return Expression.transform(this, arg1, ExpressionOperator.SUBTRACT, arg2, true, transform);
|
||||
}
|
||||
|
||||
|
||||
|
||||
// -------------------------------------------------------------------------
|
||||
// XXX: Query Object Model
|
||||
// -------------------------------------------------------------------------
|
||||
|
||||
@Override
|
||||
public final Field<T> $arg1() {
|
||||
return arg1;
|
||||
}
|
||||
|
||||
@Override
|
||||
public final Field<T> $arg2() {
|
||||
return arg2;
|
||||
}
|
||||
|
||||
@Override
|
||||
public final QOM.Sub<T> $arg1(Field<T> newValue) {
|
||||
return constructor().apply(newValue, $arg2());
|
||||
}
|
||||
|
||||
@Override
|
||||
public final QOM.Sub<T> $arg2(Field<T> newValue) {
|
||||
return constructor().apply($arg1(), newValue);
|
||||
}
|
||||
|
||||
@Override
|
||||
public final Function2<? super Field<T>, ? super Field<T>, ? extends QOM.Sub<T>> constructor() {
|
||||
return (a1, a2) -> new ISub<>(a1, a2);
|
||||
}
|
||||
|
||||
// -------------------------------------------------------------------------
|
||||
// XXX: The Object API
|
||||
// -------------------------------------------------------------------------
|
||||
|
||||
@Override
|
||||
public boolean equals(Object that) {
|
||||
if (that instanceof ISub) { ISub o = (ISub) that;
|
||||
return
|
||||
StringUtils.equals($arg1(), o.$arg1()) &&
|
||||
StringUtils.equals($arg2(), o.$arg2())
|
||||
;
|
||||
}
|
||||
else
|
||||
return super.equals(that);
|
||||
}
|
||||
}
|
||||
177
jOOQ/src/main/java/org/jooq/impl/Mul.java
Normal file
177
jOOQ/src/main/java/org/jooq/impl/Mul.java
Normal file
@ -0,0 +1,177 @@
|
||||
/*
|
||||
* 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.*;
|
||||
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.DataExtendedKey.*;
|
||||
import static org.jooq.impl.Tools.DataKey.*;
|
||||
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.Add;
|
||||
import org.jooq.impl.QOM.*;
|
||||
import org.jooq.tools.*;
|
||||
|
||||
import java.util.*;
|
||||
import java.util.function.*;
|
||||
import java.util.stream.*;
|
||||
|
||||
|
||||
/**
|
||||
* The <code>MUL</code> statement.
|
||||
*/
|
||||
@SuppressWarnings({ "rawtypes", "unchecked", "unused" })
|
||||
final class Mul<T>
|
||||
extends
|
||||
AbstractTransformable<T>
|
||||
implements
|
||||
QOM.Mul<T>
|
||||
{
|
||||
|
||||
final Field<T> arg1;
|
||||
final Field<T> arg2;
|
||||
|
||||
Mul(
|
||||
Field<T> arg1,
|
||||
Field<T> arg2
|
||||
) {
|
||||
super(
|
||||
N_MUL,
|
||||
allNotNull((DataType) dataType(arg1), arg1, arg2)
|
||||
);
|
||||
|
||||
this.arg1 = nullSafeNotNull(arg1, (DataType) OTHER);
|
||||
this.arg2 = nullSafeNotNull(arg2, (DataType) OTHER);
|
||||
}
|
||||
|
||||
// -------------------------------------------------------------------------
|
||||
// XXX: QueryPart API
|
||||
// -------------------------------------------------------------------------
|
||||
|
||||
|
||||
|
||||
@Override
|
||||
public final void accept0(Context<?> ctx) {
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
ctx.sql('(');
|
||||
Expression.<Field<T>, Mul<T>>acceptAssociative(
|
||||
ctx,
|
||||
this,
|
||||
q -> new Expression.Expr<>(q.arg1, Operators.OP_AST, q.arg2),
|
||||
c -> c.sql(' ')
|
||||
);
|
||||
ctx.sql(')');
|
||||
}
|
||||
|
||||
@Override
|
||||
public final Field<?> transform(TransformUnneededArithmeticExpressions transform) {
|
||||
return Expression.transform(this, arg1, ExpressionOperator.MULTIPLY, arg2, false, transform);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
// -------------------------------------------------------------------------
|
||||
// XXX: Query Object Model
|
||||
// -------------------------------------------------------------------------
|
||||
|
||||
@Override
|
||||
public final Field<T> $arg1() {
|
||||
return arg1;
|
||||
}
|
||||
|
||||
@Override
|
||||
public final Field<T> $arg2() {
|
||||
return arg2;
|
||||
}
|
||||
|
||||
@Override
|
||||
public final QOM.Mul<T> $arg1(Field<T> newValue) {
|
||||
return constructor().apply(newValue, $arg2());
|
||||
}
|
||||
|
||||
@Override
|
||||
public final QOM.Mul<T> $arg2(Field<T> newValue) {
|
||||
return constructor().apply($arg1(), newValue);
|
||||
}
|
||||
|
||||
@Override
|
||||
public final Function2<? super Field<T>, ? super Field<T>, ? extends QOM.Mul<T>> constructor() {
|
||||
return (a1, a2) -> new Mul<>(a1, a2);
|
||||
}
|
||||
|
||||
// -------------------------------------------------------------------------
|
||||
// XXX: The Object API
|
||||
// -------------------------------------------------------------------------
|
||||
|
||||
@Override
|
||||
public boolean equals(Object that) {
|
||||
if (that instanceof Mul) { Mul o = (Mul) that;
|
||||
return
|
||||
StringUtils.equals($arg1(), o.$arg1()) &&
|
||||
StringUtils.equals($arg2(), o.$arg2())
|
||||
;
|
||||
}
|
||||
else
|
||||
return super.equals(that);
|
||||
}
|
||||
}
|
||||
169
jOOQ/src/main/java/org/jooq/impl/Sub.java
Normal file
169
jOOQ/src/main/java/org/jooq/impl/Sub.java
Normal file
@ -0,0 +1,169 @@
|
||||
/*
|
||||
* 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.*;
|
||||
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.DataExtendedKey.*;
|
||||
import static org.jooq.impl.Tools.DataKey.*;
|
||||
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>SUB</code> statement.
|
||||
*/
|
||||
@SuppressWarnings({ "rawtypes", "unchecked", "unused" })
|
||||
final class Sub<T>
|
||||
extends
|
||||
AbstractTransformable<T>
|
||||
implements
|
||||
QOM.Sub<T>
|
||||
{
|
||||
|
||||
final Field<T> arg1;
|
||||
final Field<T> arg2;
|
||||
|
||||
Sub(
|
||||
Field<T> arg1,
|
||||
Field<T> arg2
|
||||
) {
|
||||
super(
|
||||
N_SUB,
|
||||
allNotNull((DataType) dataType(arg1), arg1, arg2)
|
||||
);
|
||||
|
||||
this.arg1 = nullSafeNotNull(arg1, (DataType) OTHER);
|
||||
this.arg2 = nullSafeNotNull(arg2, (DataType) OTHER);
|
||||
}
|
||||
|
||||
// -------------------------------------------------------------------------
|
||||
// XXX: QueryPart API
|
||||
// -------------------------------------------------------------------------
|
||||
|
||||
|
||||
|
||||
@Override
|
||||
public final void accept0(Context<?> ctx) {
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
ctx.sql('(').visit(arg1).sql(" - ").visit(arg2).sql(')');
|
||||
}
|
||||
|
||||
@Override
|
||||
public final Field<?> transform(TransformUnneededArithmeticExpressions transform) {
|
||||
return Expression.transform(this, arg1, ExpressionOperator.SUBTRACT, arg2, false, transform);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
// -------------------------------------------------------------------------
|
||||
// XXX: Query Object Model
|
||||
// -------------------------------------------------------------------------
|
||||
|
||||
@Override
|
||||
public final Field<T> $arg1() {
|
||||
return arg1;
|
||||
}
|
||||
|
||||
@Override
|
||||
public final Field<T> $arg2() {
|
||||
return arg2;
|
||||
}
|
||||
|
||||
@Override
|
||||
public final QOM.Sub<T> $arg1(Field<T> newValue) {
|
||||
return constructor().apply(newValue, $arg2());
|
||||
}
|
||||
|
||||
@Override
|
||||
public final QOM.Sub<T> $arg2(Field<T> newValue) {
|
||||
return constructor().apply($arg1(), newValue);
|
||||
}
|
||||
|
||||
@Override
|
||||
public final Function2<? super Field<T>, ? super Field<T>, ? extends QOM.Sub<T>> constructor() {
|
||||
return (a1, a2) -> new Sub<>(a1, a2);
|
||||
}
|
||||
|
||||
// -------------------------------------------------------------------------
|
||||
// XXX: The Object API
|
||||
// -------------------------------------------------------------------------
|
||||
|
||||
@Override
|
||||
public boolean equals(Object that) {
|
||||
if (that instanceof Sub) { Sub o = (Sub) that;
|
||||
return
|
||||
StringUtils.equals($arg1(), o.$arg1()) &&
|
||||
StringUtils.equals($arg2(), o.$arg2())
|
||||
;
|
||||
}
|
||||
else
|
||||
return super.equals(that);
|
||||
}
|
||||
}
|
||||
Loading…
Reference in New Issue
Block a user