diff --git a/jOOQ/src/main/java/org/jooq/AssignmentTarget.java b/jOOQ/src/main/java/org/jooq/AssignmentTarget.java new file mode 100644 index 0000000000..33413abb24 --- /dev/null +++ b/jOOQ/src/main/java/org/jooq/AssignmentTarget.java @@ -0,0 +1,59 @@ +/* + * 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; + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/jOOQ/src/main/java/org/jooq/Declaration.java b/jOOQ/src/main/java/org/jooq/Declaration.java new file mode 100644 index 0000000000..a56ac42b2c --- /dev/null +++ b/jOOQ/src/main/java/org/jooq/Declaration.java @@ -0,0 +1,51 @@ +/* + * 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; + + + + + + + + + + + + + \ No newline at end of file diff --git a/jOOQ/src/main/java/org/jooq/Variable.java b/jOOQ/src/main/java/org/jooq/Variable.java new file mode 100644 index 0000000000..b6cd2b93b1 --- /dev/null +++ b/jOOQ/src/main/java/org/jooq/Variable.java @@ -0,0 +1,49 @@ +/* + * 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; + + + + + + + + + + + \ No newline at end of file diff --git a/jOOQ/src/main/java/org/jooq/impl/Assignment.java b/jOOQ/src/main/java/org/jooq/impl/Assignment.java new file mode 100644 index 0000000000..d024a424ad --- /dev/null +++ b/jOOQ/src/main/java/org/jooq/impl/Assignment.java @@ -0,0 +1,86 @@ +/* + * 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.Keywords.K_SET; + +// ... +import org.jooq.Clause; +import org.jooq.Context; +import org.jooq.Field; + +/** + * @author Lukas Eder + */ +final class Assignment extends AbstractStatement { + + /** + * Generated UID + */ + private static final long serialVersionUID = 1567637930559064772L; + final AssignmentTarget target; + final Field value; + + Assignment(AssignmentTarget target, Field value) { + this.target = target; + this.value = value; + } + + @Override + public final void accept(Context ctx) { + switch (ctx.family()) { + case MARIADB: + case MYSQL: + case SQLSERVER: + ctx.visit(K_SET).sql(' ').visit(target).sql(" = ").visit(value); + break; + + case POSTGRES: + case ORACLE: + default: + ctx.visit(target).sql(" := ").visit(value); + break; + } + } + + @Override + public final Clause[] clauses(Context ctx) { + return null; + } +} +/* [/pro] */ \ No newline at end of file diff --git a/jOOQ/src/main/java/org/jooq/impl/BlockImpl.java b/jOOQ/src/main/java/org/jooq/impl/BlockImpl.java index d0a1ab51b8..9bd51441c0 100644 --- a/jOOQ/src/main/java/org/jooq/impl/BlockImpl.java +++ b/jOOQ/src/main/java/org/jooq/impl/BlockImpl.java @@ -48,6 +48,7 @@ import static org.jooq.conf.ParamType.INLINED; import static org.jooq.impl.Keywords.K_AS; import static org.jooq.impl.Keywords.K_ATOMIC; import static org.jooq.impl.Keywords.K_BEGIN; +import static org.jooq.impl.Keywords.K_DECLARE; import static org.jooq.impl.Keywords.K_DO; import static org.jooq.impl.Keywords.K_END; import static org.jooq.impl.Keywords.K_EXECUTE_BLOCK; @@ -59,14 +60,17 @@ import static org.jooq.impl.Tools.increment; import static org.jooq.impl.Tools.DataKey.DATA_BLOCK_NESTING; import static org.jooq.impl.Tools.DataKey.DATA_FORCE_STATIC_STATEMENT; +import java.util.ArrayList; import java.util.Collection; import java.util.EnumSet; +import java.util.List; import org.jooq.Block; import org.jooq.Clause; import org.jooq.Configuration; import org.jooq.Context; import org.jooq.DDLQuery; +// ... import org.jooq.SQLDialect; import org.jooq.Statement; @@ -82,6 +86,9 @@ final class BlockImpl extends AbstractQuery implements Block { private static final EnumSet REQUIRES_EXECUTE_IMMEDIATE_ON_DDL = EnumSet.of(FIREBIRD); private static final EnumSet SUPPORTS_NULL_STATEMENT = EnumSet.of(POSTGRES); + + + private final Collection statements; BlockImpl(Configuration configuration, Collection statements) { @@ -166,6 +173,47 @@ final class BlockImpl extends AbstractQuery implements Block { } private final void accept0(Context ctx) { + accept1(ctx, new ArrayList(statements)); + } + + private static final void accept1(Context ctx, List statements) { + + + + + + + + + + + + + + + + + + + + + + + + + + + + + accept2(ctx, statements); + } + + private static final boolean declaration(Statement statement) { + return statement instanceof Declaration + || statement instanceof Assignment && ((Assignment) statement).target instanceof Declaration; + } + + private static final void accept2(Context ctx, List statements) { ctx.visit(K_BEGIN); if (ctx.family() == MARIADB) @@ -194,7 +242,17 @@ final class BlockImpl extends AbstractQuery implements Block { } else { statementLoop: - for (Statement s : statements) { + for (int i = 0; i < statements.size(); i++) { + Statement s = statements.get(i); + + + + + + + + + if (s instanceof NullStatement && !SUPPORTS_NULL_STATEMENT.contains(ctx.family())) continue statementLoop; diff --git a/jOOQ/src/main/java/org/jooq/impl/DSL.java b/jOOQ/src/main/java/org/jooq/impl/DSL.java index 1e1591326f..c4b80793ca 100644 --- a/jOOQ/src/main/java/org/jooq/impl/DSL.java +++ b/jOOQ/src/main/java/org/jooq/impl/DSL.java @@ -175,6 +175,7 @@ import org.jooq.CreateViewAsStep; import org.jooq.DSLContext; import org.jooq.DataType; import org.jooq.DatePart; +// ... import org.jooq.Delete; import org.jooq.DeleteWhereStep; import org.jooq.DerivedColumnList; @@ -328,6 +329,7 @@ import org.jooq.UDTRecord; import org.jooq.Update; import org.jooq.UpdateSetFirstStep; import org.jooq.User; +// ... import org.jooq.WindowFromFirstLastStep; import org.jooq.WindowIgnoreNullsStep; import org.jooq.WindowOverStep; @@ -9725,6 +9727,40 @@ public class DSL { + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/jOOQ/src/main/java/org/jooq/impl/DeclarationImpl.java b/jOOQ/src/main/java/org/jooq/impl/DeclarationImpl.java new file mode 100644 index 0000000000..781e574775 --- /dev/null +++ b/jOOQ/src/main/java/org/jooq/impl/DeclarationImpl.java @@ -0,0 +1,101 @@ +/* + * 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; + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/jOOQ/src/main/java/org/jooq/impl/VariableImpl.java b/jOOQ/src/main/java/org/jooq/impl/VariableImpl.java new file mode 100644 index 0000000000..2aef2d9d07 --- /dev/null +++ b/jOOQ/src/main/java/org/jooq/impl/VariableImpl.java @@ -0,0 +1,78 @@ +/* + * 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; + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file