diff --git a/jOOQ/src/main/java/org/jooq/Table.java b/jOOQ/src/main/java/org/jooq/Table.java index 8213785ad4..0ee64cb332 100644 --- a/jOOQ/src/main/java/org/jooq/Table.java +++ b/jOOQ/src/main/java/org/jooq/Table.java @@ -344,33 +344,6 @@ public interface Table extends TableLike, RecordQualifiertable.rowid reference from this table. - *

- * A rowid value describes the physical location of a row on the disk, which - * can be used as a replacement for a primary key in some situations - - * especially within a query, e.g. to self-join a table: - *

- *

-     * -- Emulating this MySQL statement...
-     * DELETE FROM x ORDER BY x.y LIMIT 1
-     *
-     * -- ... in other databases
-     * DELETE FROM x
-     * WHERE x.rowid IN (
-     *   SELECT x.rowid FROM x ORDER BY x.a LIMIT 1
-     * )
-     * 
- *

- * It is not recommended to use rowid values in client - * applications as actual row identifiers as the database system may move a - * row to a different physical location at any time, thus changing the rowid - * value. In general, use primary keys, instead. - */ - @NotNull - @Support({ H2, POSTGRES, SQLITE }) - Field rowid(); - // ------------------------------------------------------------------------- // XXX: Aliasing clauses // ------------------------------------------------------------------------- @@ -2452,6 +2425,39 @@ public interface Table extends TableLike, RecordQualifier arg2); + // ------------------------------------------------------------------------- + // Table functions + // ------------------------------------------------------------------------- + + /** + * The ROWID operator. + *

+ * Get a table.rowid reference from this table. + *

+ * A rowid value describes the physical location of a row on the disk, which + * can be used as a replacement for a primary key in some situations - + * especially within a query, e.g. to self-join a table: + *

+ *

+     * -- Emulating this MySQL statement...
+     * DELETE FROM x ORDER BY x.y LIMIT 1
+     * 
+     * -- ... in other databases
+     * DELETE FROM x
+     * WHERE x.rowid IN (
+     * SELECT x.rowid FROM x ORDER BY x.a LIMIT 1
+     * )
+     * 
+ *

+ * It is not recommended to use rowid values in client + * applications as actual row identifiers as the database system may move a + * row to a different physical location at any time, thus changing the rowid + * value. In general, use primary keys, instead. + */ + @NotNull + @Support({ H2, POSTGRES, SQLITE }) + Field rowid(); + /** diff --git a/jOOQ/src/main/java/org/jooq/impl/AbstractTable.java b/jOOQ/src/main/java/org/jooq/impl/AbstractTable.java index 6027e8e1c2..69eec3459f 100644 --- a/jOOQ/src/main/java/org/jooq/impl/AbstractTable.java +++ b/jOOQ/src/main/java/org/jooq/impl/AbstractTable.java @@ -174,11 +174,6 @@ abstract class AbstractTable extends AbstractNamed implements return new QualifiedAsteriskImpl(this); } - @Override - public final Field rowid() { - return new RowIdField(this); - } - // ------------------------------------------------------------------------ // XXX: TableLike API // ------------------------------------------------------------------------ @@ -782,6 +777,15 @@ abstract class AbstractTable extends AbstractNamed implements return ne(arg2); } + // ------------------------------------------------------------------------- + // Table functions + // ------------------------------------------------------------------------- + + @Override + public final Field rowid() { + return new QualifiedRowid(this); + } + // ------------------------------------------------------------------------ diff --git a/jOOQ/src/main/java/org/jooq/impl/ConditionAsField.java b/jOOQ/src/main/java/org/jooq/impl/ConditionAsField.java index 07fdf9832f..3afe517ce7 100644 --- a/jOOQ/src/main/java/org/jooq/impl/ConditionAsField.java +++ b/jOOQ/src/main/java/org/jooq/impl/ConditionAsField.java @@ -74,7 +74,7 @@ extends Condition condition ) { super( - N_CONDITION_AS_FIELD, + N_FIELD, allNotNull(BOOLEAN) ); diff --git a/jOOQ/src/main/java/org/jooq/impl/DSL.java b/jOOQ/src/main/java/org/jooq/impl/DSL.java index 8e01787ebc..0fc603200a 100644 --- a/jOOQ/src/main/java/org/jooq/impl/DSL.java +++ b/jOOQ/src/main/java/org/jooq/impl/DSL.java @@ -19612,7 +19612,7 @@ public class DSL { } /** - * The XMLSERIALIZE_DOCUMENT function. + * The XMLSERIALIZE function. * * @param value is wrapped as {@link #val(Object)}. */ @@ -19623,7 +19623,7 @@ public class DSL { } /** - * The XMLSERIALIZE_DOCUMENT function. + * The XMLSERIALIZE function. */ @NotNull @Support({ POSTGRES }) @@ -19887,7 +19887,7 @@ public class DSL { } /** - * The REGR_AVG_X function. + * The REGR_AVGX function. *

* Calculate the average of the independent values (x). This standard SQL function may * be supported natively, or emulated using {@link #sum(Field)} and {@link #count(Field)}. @@ -19901,7 +19901,7 @@ public class DSL { } /** - * The REGR_AVG_Y function. + * The REGR_AVGY function. *

* Calculate the average of the dependent values (y). This standard SQL function may * be supported natively, or emulated using {@link #sum(Field)} and {@link #count(Field)}. diff --git a/jOOQ/src/main/java/org/jooq/impl/Degrees.java b/jOOQ/src/main/java/org/jooq/impl/Degrees.java index e41980f947..4dd6356e46 100644 --- a/jOOQ/src/main/java/org/jooq/impl/Degrees.java +++ b/jOOQ/src/main/java/org/jooq/impl/Degrees.java @@ -75,7 +75,7 @@ extends Field radians ) { super( - N_DEGREES, + N_DEG, allNotNull(NUMERIC, radians) ); diff --git a/jOOQ/src/main/java/org/jooq/impl/Euler.java b/jOOQ/src/main/java/org/jooq/impl/Euler.java index 450011e77d..0b2115624e 100644 --- a/jOOQ/src/main/java/org/jooq/impl/Euler.java +++ b/jOOQ/src/main/java/org/jooq/impl/Euler.java @@ -71,7 +71,7 @@ extends Euler() { super( - N_EULER, + N_E, allNotNull(NUMERIC) ); } diff --git a/jOOQ/src/main/java/org/jooq/impl/Log.java b/jOOQ/src/main/java/org/jooq/impl/Log.java index f046577626..ed5cf089e7 100644 --- a/jOOQ/src/main/java/org/jooq/impl/Log.java +++ b/jOOQ/src/main/java/org/jooq/impl/Log.java @@ -76,7 +76,7 @@ extends Field value ) { super( - N_LOG, + N_LN, allNotNull(NUMERIC, value) ); @@ -89,7 +89,7 @@ extends Field base ) { super( - N_LOG, + N_LN, allNotNull(NUMERIC, value, base) ); diff --git a/jOOQ/src/main/java/org/jooq/impl/Names.java b/jOOQ/src/main/java/org/jooq/impl/Names.java index 63bdf9d6e5..c21f4c98c2 100644 --- a/jOOQ/src/main/java/org/jooq/impl/Names.java +++ b/jOOQ/src/main/java/org/jooq/impl/Names.java @@ -119,7 +119,6 @@ final class Names { static final Name N_CHR = unquotedName("chr"); static final Name N_COALESCE = unquotedName("coalesce"); static final Name N_COLLECT = unquotedName("collect"); - static final Name N_CONDITION_AS_FIELD = unquotedName("condition_as_field"); static final Name N_CONCAT = unquotedName("concat"); static final Name N_CONNECT_BY_IS_CYCLE = unquotedName("connect_by_iscycle"); static final Name N_CONNECT_BY_IS_LEAF = unquotedName("connect_by_isleaf"); @@ -162,6 +161,7 @@ final class Names { static final Name N_DB_NAME = unquotedName("db_name"); static final Name N_DECODE = unquotedName("decode"); static final Name N_DEFAULT = unquotedName("default"); + static final Name N_DEG = unquotedName("deg"); static final Name N_DEGREES = unquotedName("degrees"); static final Name N_DELETING = unquotedName("deleting"); static final Name N_DENSE_RANK = unquotedName("dense_rank"); @@ -263,7 +263,6 @@ final class Names { static final Name N_NEWID = unquotedName("newid"); static final Name N_NEXTVAL = unquotedName("nextval"); static final Name N_NOT = unquotedName("not"); - static final Name N_NOT_FIELD = unquotedName("not_field"); static final Name N_NOW = unquotedName("now"); static final Name N_NTILE = unquotedName("ntile"); static final Name N_NULLIF = unquotedName("nullif"); @@ -287,6 +286,7 @@ final class Names { static final Name N_PRINTF = unquotedName("printf"); static final Name N_PRIOR = unquotedName("prior"); static final Name N_PRODUCT = unquotedName("product"); + static final Name N_RAD = unquotedName("rad"); static final Name N_RADIANS = unquotedName("radians"); static final Name N_RAND = unquotedName("rand"); static final Name N_RANDOM = unquotedName("random"); @@ -319,6 +319,7 @@ final class Names { static final Name N_ROUND = unquotedName("round"); static final Name N_ROUND_DOWN = unquotedName("round_down"); static final Name N_ROW = unquotedName("row"); + static final Name N_ROWID = unquotedName("rowid"); static final Name N_ROWNUM = unquotedName("rownum"); static final Name N_ROWSFROM = unquotedName("rowsfrom"); static final Name N_ROW_NUMBER = unquotedName("row_number"); diff --git a/jOOQ/src/main/java/org/jooq/impl/NotField.java b/jOOQ/src/main/java/org/jooq/impl/NotField.java index 6cb80c42e3..08e99faebb 100644 --- a/jOOQ/src/main/java/org/jooq/impl/NotField.java +++ b/jOOQ/src/main/java/org/jooq/impl/NotField.java @@ -74,7 +74,7 @@ extends Field arg1 ) { super( - N_NOT_FIELD, + N_NOT, allNotNull(BOOLEAN, arg1) ); diff --git a/jOOQ/src/main/java/org/jooq/impl/QualifiedRowid.java b/jOOQ/src/main/java/org/jooq/impl/QualifiedRowid.java new file mode 100644 index 0000000000..fecbde2bcb --- /dev/null +++ b/jOOQ/src/main/java/org/jooq/impl/QualifiedRowid.java @@ -0,0 +1,140 @@ +/* + * 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.Record; +import org.jooq.conf.*; +import org.jooq.impl.*; +import org.jooq.tools.*; + +import java.util.*; +import java.util.function.*; +import java.util.stream.*; + + +/** + * The ROWID statement. + */ +@SuppressWarnings({ "rawtypes", "unused" }) +final class QualifiedRowid +extends + AbstractField +{ + + final Table arg1; + + QualifiedRowid( + Table arg1 + ) { + super( + N_ROWID, + allNotNull(ROWID) + ); + + this.arg1 = arg1; + } + + // ------------------------------------------------------------------------- + // XXX: QueryPart API + // ------------------------------------------------------------------------- + + @Override + public final void accept(Context ctx) { + switch (ctx.family()) { + + + + + + + case H2: + ctx.visit(arg1.getQualifiedName().append(unquotedName("_rowid_"))); + break; + + case POSTGRES: + ctx.visit(arg1.getQualifiedName().append(unquotedName("ctid"))); + break; + + + + + + + + default: + ctx.visit(arg1.getQualifiedName().append(unquotedName("rowid"))); + break; + } + } + + + + + + + + + + + // ------------------------------------------------------------------------- + // The Object API + // ------------------------------------------------------------------------- + + @Override + public boolean equals(Object that) { + if (that instanceof QualifiedRowid) { + return + StringUtils.equals(arg1, ((QualifiedRowid) that).arg1) + ; + } + else + return super.equals(that); + } +} diff --git a/jOOQ/src/main/java/org/jooq/impl/Radians.java b/jOOQ/src/main/java/org/jooq/impl/Radians.java index 70903b9a62..0f5126db09 100644 --- a/jOOQ/src/main/java/org/jooq/impl/Radians.java +++ b/jOOQ/src/main/java/org/jooq/impl/Radians.java @@ -75,7 +75,7 @@ extends Field degrees ) { super( - N_RADIANS, + N_RAD, allNotNull(NUMERIC, degrees) ); diff --git a/jOOQ/src/main/java/org/jooq/impl/RegrAvgx.java b/jOOQ/src/main/java/org/jooq/impl/RegrAvgx.java index ec8549a456..0e8b97a99b 100644 --- a/jOOQ/src/main/java/org/jooq/impl/RegrAvgx.java +++ b/jOOQ/src/main/java/org/jooq/impl/RegrAvgx.java @@ -61,7 +61,7 @@ import java.math.BigDecimal; /** - * The REGR AVG X statement. + * The REGR AVGX statement. */ @SuppressWarnings({ "rawtypes", "unused" }) final class RegrAvgx diff --git a/jOOQ/src/main/java/org/jooq/impl/RegrAvgy.java b/jOOQ/src/main/java/org/jooq/impl/RegrAvgy.java index 1ad482a0d6..4a99203189 100644 --- a/jOOQ/src/main/java/org/jooq/impl/RegrAvgy.java +++ b/jOOQ/src/main/java/org/jooq/impl/RegrAvgy.java @@ -61,7 +61,7 @@ import java.math.BigDecimal; /** - * The REGR AVG Y statement. + * The REGR AVGY statement. */ @SuppressWarnings({ "rawtypes", "unused" }) final class RegrAvgy diff --git a/jOOQ/src/main/java/org/jooq/impl/RowIdField.java b/jOOQ/src/main/java/org/jooq/impl/RowIdField.java deleted file mode 100644 index 9130fa1b44..0000000000 --- a/jOOQ/src/main/java/org/jooq/impl/RowIdField.java +++ /dev/null @@ -1,84 +0,0 @@ -/* - * 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.unquotedName; - -import org.jooq.Context; -import org.jooq.RowId; -import org.jooq.Table; - -/** - * @author Lukas Eder - */ -final class RowIdField extends AbstractField { - private final Table table; - - RowIdField(Table table) { - super(table.getQualifiedName().append(unquotedName("rowid")), SQLDataType.ROWID); - - this.table = table; - } - - @Override - public final void accept(Context ctx) { - switch (ctx.family()) { - case H2: - ctx.visit(table.getQualifiedName().append(unquotedName("_rowid_"))); - break; - - case POSTGRES: - ctx.visit(table.getQualifiedName().append(unquotedName("ctid"))); - break; - - - - - - - - - - - - default: - ctx.visit(getQualifiedName()); - break; - } - } -} diff --git a/jOOQ/src/main/java/org/jooq/impl/Xmlserialize.java b/jOOQ/src/main/java/org/jooq/impl/Xmlserialize.java index 4396521ed2..daa996343c 100644 --- a/jOOQ/src/main/java/org/jooq/impl/Xmlserialize.java +++ b/jOOQ/src/main/java/org/jooq/impl/Xmlserialize.java @@ -60,7 +60,7 @@ import java.util.stream.*; /** - * The XMLSERIALIZE DOCUMENT statement. + * The XMLSERIALIZE statement. */ @SuppressWarnings({ "rawtypes", "unchecked", "unused" }) final class Xmlserialize