From d24ce2b180ea8b3ec19b7e59eba883738cc05004 Mon Sep 17 00:00:00 2001 From: lukaseder Date: Sat, 3 Jan 2015 12:23:32 +0100 Subject: [PATCH] Version 3.5.1 - January 03, 2015 ================================================================================ This is a patch release with some useful fixes for the 3.5 branch Bug fixes --------- #3378 - Error when fully qualifying PostgreSQL table-valued functions in SELECT clauses #3803 - CREATE TABLE statement does not generate NOT NULL constraint #3811 - Potential NullPointerException in Cursor.fetchOne(RecordMapper) and other methods #3817 - When used with set operations, ORDER BY must not contain any qualified fields #3819 - Add Constants.XSD_META and Constants.NS_META to describe the new jooq-meta-x.x.xsd #3822 - Invalid SQL for Postgres created with values(Row1...) #3824 - PostgreSQL dateAdd() erroneously returns a TIMESTAMP value #3831 - deprecation warning is displayed even if the flag is not active #3833 - org.jooq.CreateTableAsStep.column(Field field, DataType type) SQLite #3835 - SQLite's CREATE VIEW statement doesn't allow to rename columns #3838 - Bad @Support annotations on ALTER TABLE statements, which are not supported by SQLite #3855 - Oracle REAL and FLOAT types cause code generator to produce BigInteger instead of Double types #3863 - CSV-Export with delimiter only does not work properly #3880 - Cannot access private JavaGenerator.newJavaWriter() method #3888 - Data type conversion fails when using a Binding and passing a byte[] as user input #3895 The free trial version no longer works after Jan 01, 2015 --- jOOQ-codegen-maven/pom.xml | 2 +- jOOQ-codegen/pom.xml | 2 +- .../java/org/jooq/util/GenerationTool.java | 2 +- .../java/org/jooq/util/JavaGenerator.java | 9 +- jOOQ-examples/jOOQ-flyway-example/pom.xml | 2 +- jOOQ-examples/jOOQ-jax-rs-example/pom.xml | 4 +- jOOQ-examples/jOOQ-nashorn-example/pom.xml | 2 +- jOOQ-examples/jOOQ-oracle-example/pom.xml | 2 +- jOOQ-examples/jOOQ-spring-example/pom.xml | 2 +- .../jOOQ-spring-guice-example/pom.xml | 2 +- jOOQ-examples/jOOQ-vertabelo-example/pom.xml | 2 +- jOOQ-meta/pom.xml | 2 +- jOOQ-release/build.xml | 2 +- .../release/template/RELEASE-NOTES.txt.regex | 16 ++++ .../release/template/RELEASENOTES.txt | 27 +++++- .../release/template/maven-install.bat | 2 +- .../release/template/maven-install.sh | 2 +- jOOQ-scala/pom.xml | 4 +- jOOQ/pom.xml | 2 +- .../main/java/org/jooq/AlterTableStep.java | 25 +++++- jOOQ/src/main/java/org/jooq/Constants.java | 14 +++- jOOQ/src/main/java/org/jooq/RecordMapper.java | 2 + .../java/org/jooq/impl/CreateTableImpl.java | 9 ++ .../java/org/jooq/impl/CreateViewImpl.java | 15 +++- .../main/java/org/jooq/impl/CursorImpl.java | 3 +- jOOQ/src/main/java/org/jooq/impl/DAOImpl.java | 4 +- jOOQ/src/main/java/org/jooq/impl/DSL.java | 9 +- jOOQ/src/main/java/org/jooq/impl/DateAdd.java | 9 +- .../main/java/org/jooq/impl/Expression.java | 4 +- .../main/java/org/jooq/impl/ResultImpl.java | 2 +- jOOQ/src/main/java/org/jooq/impl/RowImpl.java | 83 +++++++++---------- .../java/org/jooq/impl/SelectQueryImpl.java | 19 +++-- .../main/java/org/jooq/impl/TableImpl.java | 3 +- .../test/java/org/jooq/test/BasicTest.java | 8 +- pom.xml | 4 +- 35 files changed, 207 insertions(+), 94 deletions(-) create mode 100644 jOOQ-release/release/template/RELEASE-NOTES.txt.regex diff --git a/jOOQ-codegen-maven/pom.xml b/jOOQ-codegen-maven/pom.xml index 8dc297574c..ea8ab6d929 100644 --- a/jOOQ-codegen-maven/pom.xml +++ b/jOOQ-codegen-maven/pom.xml @@ -6,7 +6,7 @@ org.jooq jooq-parent - 3.5.0 + 3.5.1 org.jooq diff --git a/jOOQ-codegen/pom.xml b/jOOQ-codegen/pom.xml index 6f29d5e120..134ab5e5ad 100644 --- a/jOOQ-codegen/pom.xml +++ b/jOOQ-codegen/pom.xml @@ -7,7 +7,7 @@ org.jooq jooq-parent - 3.5.0 + 3.5.1 org.jooq diff --git a/jOOQ-codegen/src/main/java/org/jooq/util/GenerationTool.java b/jOOQ-codegen/src/main/java/org/jooq/util/GenerationTool.java index 09afb7399a..0d29451aa1 100644 --- a/jOOQ-codegen/src/main/java/org/jooq/util/GenerationTool.java +++ b/jOOQ-codegen/src/main/java/org/jooq/util/GenerationTool.java @@ -341,7 +341,7 @@ else if (schema.getOutputSchema() == null) { if (d.getEnumTypes().size() > 0) log.warn("DEPRECATED", "The configuration property /configuration/generator/database/enumTypes is experimental and deprecated and will be removed in the future."); - if (d.isDateAsTimestamp() != null) + if (Boolean.TRUE.equals(d.isDateAsTimestamp())) log.warn("DEPRECATED", "The configuration property /configuration/generator/database/dateAsTimestamp is deprecated as it is superseded by custom bindings and converters. It will thus be removed in the future."); if (d.isDateAsTimestamp() != null) diff --git a/jOOQ-codegen/src/main/java/org/jooq/util/JavaGenerator.java b/jOOQ-codegen/src/main/java/org/jooq/util/JavaGenerator.java index 0cbb40257b..1cd13e422e 100644 --- a/jOOQ-codegen/src/main/java/org/jooq/util/JavaGenerator.java +++ b/jOOQ-codegen/src/main/java/org/jooq/util/JavaGenerator.java @@ -2104,7 +2104,11 @@ protected void generateTable(SchemaDefinition schema, TableDefinition table) { out.println(); out.tab(1).println("private %s(%s alias, %s<%s> aliased) {", className, String.class, Table.class, recordType); - out.tab(2).println("this(alias, aliased, null);"); + if (table.isTableValuedFunction()) + out.tab(2).println("this(alias, aliased, new %s[%s]);", Field.class, table.getParameters().size()); + else + out.tab(2).println("this(alias, aliased, null);"); + out.tab(1).println("}"); out.println(); @@ -3380,7 +3384,8 @@ private static final List list(T... objects) { return result; } - private final JavaWriter newJavaWriter(File file) { + // [#3880] Users may need to call this method + protected final JavaWriter newJavaWriter(File file) { files.add(file); return new JavaWriter(file); } diff --git a/jOOQ-examples/jOOQ-flyway-example/pom.xml b/jOOQ-examples/jOOQ-flyway-example/pom.xml index 0bb16ccb61..14760aa6be 100644 --- a/jOOQ-examples/jOOQ-flyway-example/pom.xml +++ b/jOOQ-examples/jOOQ-flyway-example/pom.xml @@ -19,7 +19,7 @@ UTF-8 3.2.6.RELEASE - 3.5.0 + 3.5.1 jdbc:h2:~/flyway-test sa diff --git a/jOOQ-examples/jOOQ-jax-rs-example/pom.xml b/jOOQ-examples/jOOQ-jax-rs-example/pom.xml index 2c83abc9ca..2187dab954 100644 --- a/jOOQ-examples/jOOQ-jax-rs-example/pom.xml +++ b/jOOQ-examples/jOOQ-jax-rs-example/pom.xml @@ -35,7 +35,7 @@ org.jooq jooq-codegen-maven - 3.5.0 + 3.5.1 @@ -108,7 +108,7 @@ org.jooq jooq - 3.5.0 + 3.5.1 org.postgresql diff --git a/jOOQ-examples/jOOQ-nashorn-example/pom.xml b/jOOQ-examples/jOOQ-nashorn-example/pom.xml index a2dc54c8c4..a32203d514 100644 --- a/jOOQ-examples/jOOQ-nashorn-example/pom.xml +++ b/jOOQ-examples/jOOQ-nashorn-example/pom.xml @@ -19,7 +19,7 @@ UTF-8 3.2.6.RELEASE - 3.5.0 + 3.5.1 diff --git a/jOOQ-examples/jOOQ-oracle-example/pom.xml b/jOOQ-examples/jOOQ-oracle-example/pom.xml index 08582a625f..9dcc0f6e42 100644 --- a/jOOQ-examples/jOOQ-oracle-example/pom.xml +++ b/jOOQ-examples/jOOQ-oracle-example/pom.xml @@ -18,7 +18,7 @@ UTF-8 - 3.5.0 + 3.5.1 11 diff --git a/jOOQ-examples/jOOQ-spring-example/pom.xml b/jOOQ-examples/jOOQ-spring-example/pom.xml index 1c46ae5a4d..55a326dde1 100644 --- a/jOOQ-examples/jOOQ-spring-example/pom.xml +++ b/jOOQ-examples/jOOQ-spring-example/pom.xml @@ -19,7 +19,7 @@ UTF-8 4.1.2.RELEASE - 3.5.0 + 3.5.1 1.8 diff --git a/jOOQ-examples/jOOQ-spring-guice-example/pom.xml b/jOOQ-examples/jOOQ-spring-guice-example/pom.xml index c843593a7c..bbbac91e11 100644 --- a/jOOQ-examples/jOOQ-spring-guice-example/pom.xml +++ b/jOOQ-examples/jOOQ-spring-guice-example/pom.xml @@ -19,7 +19,7 @@ UTF-8 4.1.2.RELEASE - 3.5.0 + 3.5.1 diff --git a/jOOQ-examples/jOOQ-vertabelo-example/pom.xml b/jOOQ-examples/jOOQ-vertabelo-example/pom.xml index a1be82cc8d..15614a8863 100644 --- a/jOOQ-examples/jOOQ-vertabelo-example/pom.xml +++ b/jOOQ-examples/jOOQ-vertabelo-example/pom.xml @@ -19,7 +19,7 @@ UTF-8 3.2.6.RELEASE - 3.5.0 + 3.5.1 diff --git a/jOOQ-meta/pom.xml b/jOOQ-meta/pom.xml index 439ab7eaea..3a8778591b 100644 --- a/jOOQ-meta/pom.xml +++ b/jOOQ-meta/pom.xml @@ -6,7 +6,7 @@ org.jooq jooq-parent - 3.5.0 + 3.5.1 org.jooq diff --git a/jOOQ-release/build.xml b/jOOQ-release/build.xml index 80a14e1b59..d9943e82c4 100644 --- a/jOOQ-release/build.xml +++ b/jOOQ-release/build.xml @@ -3,7 +3,7 @@ - + diff --git a/jOOQ-release/release/template/RELEASE-NOTES.txt.regex b/jOOQ-release/release/template/RELEASE-NOTES.txt.regex new file mode 100644 index 0000000000..b41905adc5 --- /dev/null +++ b/jOOQ-release/release/template/RELEASE-NOTES.txt.regex @@ -0,0 +1,16 @@ +Sophisticated GitHub issue export script + +- "Export" from GitHub via copy paste +- Apply regexes: + o search ^\s*\d+$\n + replace + + o search ^#\d+.*?$\n + replace + + o search ^\s*(.*?) - Merge \[(.*?)\].*?$ + replace $2 - $1 + + +------------------------------------- + diff --git a/jOOQ-release/release/template/RELEASENOTES.txt b/jOOQ-release/release/template/RELEASENOTES.txt index 61af4b1bbe..b3f3347536 100644 --- a/jOOQ-release/release/template/RELEASENOTES.txt +++ b/jOOQ-release/release/template/RELEASENOTES.txt @@ -10,7 +10,32 @@ http://www.jooq.org/notes.php For a text version, see http://www.jooq.org/inc/RELEASENOTES.txt -Version 3.5.0 - September 19, 2014 +Version 3.5.1 - January 03, 2015 +================================================================================ + +This is a patch release with some useful fixes for the 3.5 branch + +Bug fixes +--------- +#3378 - Error when fully qualifying PostgreSQL table-valued functions in SELECT clauses +#3803 - CREATE TABLE statement does not generate NOT NULL constraint +#3811 - Potential NullPointerException in Cursor.fetchOne(RecordMapper) and other methods +#3817 - When used with set operations, ORDER BY must not contain any qualified fields +#3819 - Add Constants.XSD_META and Constants.NS_META to describe the new jooq-meta-x.x.xsd +#3822 - Invalid SQL for Postgres created with values(Row1...) +#3824 - PostgreSQL dateAdd() erroneously returns a TIMESTAMP value +#3831 - deprecation warning is displayed even if the flag is not active +#3833 - org.jooq.CreateTableAsStep.column(Field field, DataType type) SQLite +#3835 - SQLite's CREATE VIEW statement doesn't allow to rename columns +#3838 - Bad @Support annotations on ALTER TABLE statements, which are not supported by SQLite +#3855 - Oracle REAL and FLOAT types cause code generator to produce BigInteger instead of Double types +#3863 - CSV-Export with delimiter only does not work properly +#3880 - Cannot access private JavaGenerator.newJavaWriter() method +#3888 - Data type conversion fails when using a Binding and passing a byte[] as user input +#3895 The free trial version no longer works after Jan 01, 2015 + + +Version 3.5.0 - November 21, 2014 ================================================================================ The new Binding SPI diff --git a/jOOQ-release/release/template/maven-install.bat b/jOOQ-release/release/template/maven-install.bat index df05555ec7..3dbef25425 100644 --- a/jOOQ-release/release/template/maven-install.bat +++ b/jOOQ-release/release/template/maven-install.bat @@ -1,5 +1,5 @@ @echo off -set VERSION=3.5.0 +set VERSION=3.5.1 if exist jOOQ-javadoc\jooq-%VERSION%-javadoc.jar ( set JAVADOC_JOOQ=-Djavadoc=jOOQ-javadoc\jooq-%VERSION%-javadoc.jar diff --git a/jOOQ-release/release/template/maven-install.sh b/jOOQ-release/release/template/maven-install.sh index ebafec9af6..453e76b038 100644 --- a/jOOQ-release/release/template/maven-install.sh +++ b/jOOQ-release/release/template/maven-install.sh @@ -1,5 +1,5 @@ #!/bin/sh -VERSION=3.5.0 +VERSION=3.5.1 if [ -f jOOQ-javadoc/jooq-$VERSION-javadoc.jar ]; then JAVADOC_JOOQ=-Djavadoc=jOOQ-javadoc/jooq-$VERSION-javadoc.jar diff --git a/jOOQ-scala/pom.xml b/jOOQ-scala/pom.xml index 49e673bb80..d3f1f28470 100644 --- a/jOOQ-scala/pom.xml +++ b/jOOQ-scala/pom.xml @@ -7,7 +7,7 @@ org.jooq jooq-parent - 3.5.0 + 3.5.1 org.jooq @@ -68,7 +68,7 @@ org.jooq jooq-codegen-maven - 3.5.0 + 3.5.1 exec1 diff --git a/jOOQ/pom.xml b/jOOQ/pom.xml index 665b8903fb..4dddd747b1 100644 --- a/jOOQ/pom.xml +++ b/jOOQ/pom.xml @@ -7,7 +7,7 @@ org.jooq jooq-parent - 3.5.0 + 3.5.1 org.jooq diff --git a/jOOQ/src/main/java/org/jooq/AlterTableStep.java b/jOOQ/src/main/java/org/jooq/AlterTableStep.java index cc712f0bdb..100b508246 100644 --- a/jOOQ/src/main/java/org/jooq/AlterTableStep.java +++ b/jOOQ/src/main/java/org/jooq/AlterTableStep.java @@ -40,6 +40,23 @@ */ package org.jooq; +// ... +// ... +import static org.jooq.SQLDialect.CUBRID; +// ... +import static org.jooq.SQLDialect.DERBY; +import static org.jooq.SQLDialect.FIREBIRD; +import static org.jooq.SQLDialect.H2; +import static org.jooq.SQLDialect.HSQLDB; +// ... +// ... +import static org.jooq.SQLDialect.MARIADB; +import static org.jooq.SQLDialect.MYSQL; +// ... +import static org.jooq.SQLDialect.POSTGRES; +// ... +// ... + /** * The step in the ALTER TABLE where the action can be decided. @@ -52,14 +69,14 @@ public interface AlterTableStep { * Add an ALTER COLUMN clause to the ALTER TABLE * statement. */ - @Support + @Support({ CUBRID, DERBY, FIREBIRD, H2, HSQLDB, MARIADB, MYSQL, POSTGRES }) AlterTableAlterStep alter(Field field); /** * Add an ALTER COLUMN clause to the ALTER TABLE * statement. */ - @Support + @Support({ CUBRID, DERBY, FIREBIRD, H2, HSQLDB, MARIADB, MYSQL, POSTGRES }) AlterTableAlterStep alter(String field); /** @@ -80,13 +97,13 @@ public interface AlterTableStep { * Add an DROP COLUMN clause to the ALTER TABLE * statement. */ - @Support + @Support({ CUBRID, DERBY, FIREBIRD, H2, HSQLDB, MARIADB, MYSQL, POSTGRES }) AlterTableDropStep drop(Field field); /** * Add an DROP COLUMN clause to the ALTER TABLE * statement. */ - @Support + @Support({ CUBRID, DERBY, FIREBIRD, H2, HSQLDB, MARIADB, MYSQL, POSTGRES }) AlterTableDropStep drop(String field); } diff --git a/jOOQ/src/main/java/org/jooq/Constants.java b/jOOQ/src/main/java/org/jooq/Constants.java index 9ba70a3e11..5728a0b557 100644 --- a/jOOQ/src/main/java/org/jooq/Constants.java +++ b/jOOQ/src/main/java/org/jooq/Constants.java @@ -58,7 +58,7 @@ public final class Constants { * This is the same as {@link #MINOR_VERSION}, but it may include patch * version suffixes. */ - public static final String VERSION = "3.5.0"; + public static final String VERSION = "3.5.1"; /** * The latest jOOQ full version. @@ -66,7 +66,7 @@ public final class Constants { * This is the same as {@link #VERSION}, but it may include release * candidate and other suffixes. */ - public static final String FULL_VERSION = "3.5.0"; + public static final String FULL_VERSION = "3.5.1"; /** * The current jooq-runtime XSD file name. @@ -78,6 +78,16 @@ public final class Constants { */ public static final String NS_RUNTIME = "http://www.jooq.org/xsd/" + XSD_RUNTIME; + /** + * The current jooq-meta XSD file name. + */ + public static final String XSD_META = "jooq-meta-3.5.0.xsd"; + + /** + * The current jooq-meta XML namespace. + */ + public static final String NS_META = "http://www.jooq.org/xsd/" + XSD_META; + /** * The current jooq-codegen XSD file name. */ diff --git a/jOOQ/src/main/java/org/jooq/RecordMapper.java b/jOOQ/src/main/java/org/jooq/RecordMapper.java index f4859f8dda..dd241999d1 100644 --- a/jOOQ/src/main/java/org/jooq/RecordMapper.java +++ b/jOOQ/src/main/java/org/jooq/RecordMapper.java @@ -51,6 +51,8 @@ public interface RecordMapper { /** * A callback method indicating that the next record has been fetched. + * + * @param record The record to be mapped. This is never null. */ E map(R record); } diff --git a/jOOQ/src/main/java/org/jooq/impl/CreateTableImpl.java b/jOOQ/src/main/java/org/jooq/impl/CreateTableImpl.java index be4e953d56..118322ec07 100644 --- a/jOOQ/src/main/java/org/jooq/impl/CreateTableImpl.java +++ b/jOOQ/src/main/java/org/jooq/impl/CreateTableImpl.java @@ -148,15 +148,24 @@ public final void accept(Context ctx) { .formatIndentStart() .formatNewLine(); + boolean qualify = ctx.qualify(); + ctx.qualify(false); + for (int i = 0; i < columnFields.size(); i++) { ctx.visit(columnFields.get(i)) .sql(" ") .sql(columnTypes.get(i).getCastTypeName(ctx.configuration())); + if (columnTypes.get(i).nullable()) + ctx.sql(" ").keyword("null"); + else + ctx.sql(" ").keyword("not null"); + if (i < columnFields.size() - 1) ctx.sql(",").formatSeparator(); } + ctx.qualify(qualify); ctx.formatIndentEnd() .formatNewLine() .sql(")") diff --git a/jOOQ/src/main/java/org/jooq/impl/CreateViewImpl.java b/jOOQ/src/main/java/org/jooq/impl/CreateViewImpl.java index 68bde73a38..3c12f0acbe 100644 --- a/jOOQ/src/main/java/org/jooq/impl/CreateViewImpl.java +++ b/jOOQ/src/main/java/org/jooq/impl/CreateViewImpl.java @@ -43,6 +43,9 @@ import static org.jooq.Clause.CREATE_VIEW; import static org.jooq.Clause.CREATE_VIEW_AS; import static org.jooq.Clause.CREATE_VIEW_NAME; +import static org.jooq.SQLDialect.SQLITE; +import static org.jooq.impl.DSL.selectFrom; +import static org.jooq.impl.DSL.table; import org.jooq.Clause; import org.jooq.Configuration; @@ -97,12 +100,17 @@ public final CreateViewFinalStep as(Select s) { @Override public final void accept(Context ctx) { + + // [#3835] SQLite doesn't like renaming columns at the view level + boolean rename = fields != null && fields.length > 0; + boolean renameSupported = ctx.family() != SQLITE; + ctx.start(CREATE_VIEW_NAME) .keyword("create view") .sql(" ") .visit(view); - if (fields != null && fields.length > 0) { + if (rename && renameSupported) { boolean qualify = ctx.qualify(); ctx.sql("(") @@ -117,7 +125,10 @@ public final void accept(Context ctx) { .keyword("as") .formatSeparator() .start(CREATE_VIEW_AS) - .visit(select) + .visit( + rename && !renameSupported + ? selectFrom(table(select).as("t", Utils.fieldNames(fields))) + : select) .end(CREATE_VIEW_AS); } diff --git a/jOOQ/src/main/java/org/jooq/impl/CursorImpl.java b/jOOQ/src/main/java/org/jooq/impl/CursorImpl.java index 97567bf2a1..445f17216c 100644 --- a/jOOQ/src/main/java/org/jooq/impl/CursorImpl.java +++ b/jOOQ/src/main/java/org/jooq/impl/CursorImpl.java @@ -227,7 +227,8 @@ public final > H fetchInto(H handler) { @Override public final E fetchOne(RecordMapper mapper) { - return mapper.map(fetchOne()); + R record = fetchOne(); + return record == null ? null : mapper.map(record); } @Override diff --git a/jOOQ/src/main/java/org/jooq/impl/DAOImpl.java b/jOOQ/src/main/java/org/jooq/impl/DAOImpl.java index 0f617b1b2a..42fcf11113 100644 --- a/jOOQ/src/main/java/org/jooq/impl/DAOImpl.java +++ b/jOOQ/src/main/java/org/jooq/impl/DAOImpl.java @@ -261,7 +261,7 @@ record = using(configuration) .fetchOne(); } - return mapper().map(record); + return record == null ? null : mapper().map(record); } @Override @@ -280,7 +280,7 @@ public final P fetchOne(Field field, Z value) { .where(field.equal(value)) .fetchOne(); - return mapper().map(record); + return record == null ? null : mapper().map(record); } @Override diff --git a/jOOQ/src/main/java/org/jooq/impl/DSL.java b/jOOQ/src/main/java/org/jooq/impl/DSL.java index d70ea507ac..9ff374a9ca 100644 --- a/jOOQ/src/main/java/org/jooq/impl/DSL.java +++ b/jOOQ/src/main/java/org/jooq/impl/DSL.java @@ -10875,7 +10875,14 @@ public static Param val(Object value, DataType type) { * @return The most specific data type */ private static DataType mostSpecific(T value, DataType dataType) { - if (value != null) { + + // [#3888] With custom data type conversion, users may wish to + // allow for a less specific data type than the actual value. Example: + // data type: Serializable + // value : byte[] + // [#3889] TODO: Improve this once DataType.getBinding() is available + + if (value != null && !(dataType instanceof ConvertedDataType)) { Class valueType = (Class) value.getClass(); Class coercionType = dataType.getType(); diff --git a/jOOQ/src/main/java/org/jooq/impl/DateAdd.java b/jOOQ/src/main/java/org/jooq/impl/DateAdd.java index af0c7436ae..58160f62af 100644 --- a/jOOQ/src/main/java/org/jooq/impl/DateAdd.java +++ b/jOOQ/src/main/java/org/jooq/impl/DateAdd.java @@ -44,6 +44,8 @@ import static org.jooq.impl.DSL.inline; import static org.jooq.impl.DSL.keyword; +import java.sql.Date; + import org.jooq.Configuration; import org.jooq.DatePart; import org.jooq.Field; @@ -148,7 +150,12 @@ final QueryPart getFunction0(Configuration configuration) { default: throwUnsupported(); } - return date.add(field("({0} || {1})::interval", interval, inline(keyword))); + // [#3824] Ensure that the output for DATE arithmetic will also + // be of type DATE, not TIMESTAMP + if (getDataType().getType() == Date.class) + return field("({0} + ({1} || {2})::interval)::date", getDataType(), date, interval, inline(keyword)); + else + return field("({0} + ({1} || {2})::interval)", getDataType(), date, interval, inline(keyword)); } case SQLITE: { diff --git a/jOOQ/src/main/java/org/jooq/impl/Expression.java b/jOOQ/src/main/java/org/jooq/impl/Expression.java index 4d99a20c7a..0d1d373a42 100644 --- a/jOOQ/src/main/java/org/jooq/impl/Expression.java +++ b/jOOQ/src/main/java/org/jooq/impl/Expression.java @@ -570,10 +570,10 @@ private final Field getNumberExpression(Configuration configuration) { // with incompatible data types and timezones // ? + CAST (? || ' days' as interval) if (operator == ADD) { - return lhs.add(rhsAsNumber().concat(" day").cast(DayToSecond.class)); + return new DateAdd(lhs, rhsAsNumber(), DatePart.DAY); } else { - return lhs.sub(rhsAsNumber().concat(" day").cast(DayToSecond.class)); + return new DateAdd(lhs, rhsAsNumber().neg(), DatePart.DAY); } } diff --git a/jOOQ/src/main/java/org/jooq/impl/ResultImpl.java b/jOOQ/src/main/java/org/jooq/impl/ResultImpl.java index 0864d0b7c8..2b5b195950 100644 --- a/jOOQ/src/main/java/org/jooq/impl/ResultImpl.java +++ b/jOOQ/src/main/java/org/jooq/impl/ResultImpl.java @@ -593,7 +593,7 @@ public final void formatCSV(OutputStream stream, char delimiter) { @Override public final void formatCSV(Writer writer, char delimiter) { - formatCSV(delimiter, ""); + formatCSV(writer, delimiter, ""); } @Override diff --git a/jOOQ/src/main/java/org/jooq/impl/RowImpl.java b/jOOQ/src/main/java/org/jooq/impl/RowImpl.java index baa237bf8a..3cba642529 100644 --- a/jOOQ/src/main/java/org/jooq/impl/RowImpl.java +++ b/jOOQ/src/main/java/org/jooq/impl/RowImpl.java @@ -49,16 +49,7 @@ import javax.annotation.Generated; -import org.jooq.BetweenAndStepN; import org.jooq.BetweenAndStep1; -import org.jooq.BetweenAndStep2; -import org.jooq.BetweenAndStep3; -import org.jooq.BetweenAndStep4; -import org.jooq.BetweenAndStep5; -import org.jooq.BetweenAndStep6; -import org.jooq.BetweenAndStep7; -import org.jooq.BetweenAndStep8; -import org.jooq.BetweenAndStep9; import org.jooq.BetweenAndStep10; import org.jooq.BetweenAndStep11; import org.jooq.BetweenAndStep12; @@ -69,9 +60,18 @@ import org.jooq.BetweenAndStep17; import org.jooq.BetweenAndStep18; import org.jooq.BetweenAndStep19; +import org.jooq.BetweenAndStep2; import org.jooq.BetweenAndStep20; import org.jooq.BetweenAndStep21; import org.jooq.BetweenAndStep22; +import org.jooq.BetweenAndStep3; +import org.jooq.BetweenAndStep4; +import org.jooq.BetweenAndStep5; +import org.jooq.BetweenAndStep6; +import org.jooq.BetweenAndStep7; +import org.jooq.BetweenAndStep8; +import org.jooq.BetweenAndStep9; +import org.jooq.BetweenAndStepN; import org.jooq.Clause; import org.jooq.Comparator; import org.jooq.Condition; @@ -81,14 +81,6 @@ import org.jooq.QuantifiedSelect; import org.jooq.Record; import org.jooq.Record1; -import org.jooq.Record2; -import org.jooq.Record3; -import org.jooq.Record4; -import org.jooq.Record5; -import org.jooq.Record6; -import org.jooq.Record7; -import org.jooq.Record8; -import org.jooq.Record9; import org.jooq.Record10; import org.jooq.Record11; import org.jooq.Record12; @@ -99,20 +91,20 @@ import org.jooq.Record17; import org.jooq.Record18; import org.jooq.Record19; +import org.jooq.Record2; import org.jooq.Record20; import org.jooq.Record21; import org.jooq.Record22; +import org.jooq.Record3; +import org.jooq.Record4; +import org.jooq.Record5; +import org.jooq.Record6; +import org.jooq.Record7; +import org.jooq.Record8; +import org.jooq.Record9; +import org.jooq.Result; import org.jooq.Row; -import org.jooq.RowN; import org.jooq.Row1; -import org.jooq.Row2; -import org.jooq.Row3; -import org.jooq.Row4; -import org.jooq.Row5; -import org.jooq.Row6; -import org.jooq.Row7; -import org.jooq.Row8; -import org.jooq.Row9; import org.jooq.Row10; import org.jooq.Row11; import org.jooq.Row12; @@ -123,10 +115,18 @@ import org.jooq.Row17; import org.jooq.Row18; import org.jooq.Row19; +import org.jooq.Row2; import org.jooq.Row20; import org.jooq.Row21; import org.jooq.Row22; -import org.jooq.Result; +import org.jooq.Row3; +import org.jooq.Row4; +import org.jooq.Row5; +import org.jooq.Row6; +import org.jooq.Row7; +import org.jooq.Row8; +import org.jooq.Row9; +import org.jooq.RowN; import org.jooq.Select; /** @@ -192,28 +192,23 @@ class RowImpl context) { - if (fields.fields.length == 1) { - context.visit(fields.fields[0]); - } - else { - - /* [pro] xx - xx xxxxxxxxxxxxxxxxx xx xxxxxxxxx - xxxxxxxxxxxxxxxxxxxxxxxxxxxx xxx - xx [/pro] */ - context.sql("("); + /* [pro] xx + xx xxxxxxxxxxxxxxxxx xx xxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxxxxxxx xxx - String separator = ""; - for (Field field : fields.fields) { - context.sql(separator); - context.visit(field); + xx [/pro] */ + context.sql("("); - separator = ", "; - } + String separator = ""; + for (Field field : fields.fields) { + context.sql(separator); + context.visit(field); - context.sql(")"); + separator = ", "; } + + context.sql(")"); } @Override diff --git a/jOOQ/src/main/java/org/jooq/impl/SelectQueryImpl.java b/jOOQ/src/main/java/org/jooq/impl/SelectQueryImpl.java index bc36bc00f9..5ffa4e65e7 100644 --- a/jOOQ/src/main/java/org/jooq/impl/SelectQueryImpl.java +++ b/jOOQ/src/main/java/org/jooq/impl/SelectQueryImpl.java @@ -1126,12 +1126,19 @@ else if (asList(CUBRID, DERBY, FIREBIRD, HSQLDB, MARIADB, MYSQL, POSTGRES, SQLIT // ORDER BY clause for UNION // ------------------------- - toSQLOrderBy( - context, - originalFields, alternativeFields, - wrapQueryExpressionInDerivedTable, wrapQueryExpressionBodyInDerivedTable, - unionOrderBy, unionLimit - ); + boolean qualify = context.qualify(); + try { + context.qualify(false); + toSQLOrderBy( + context, + originalFields, alternativeFields, + wrapQueryExpressionInDerivedTable, wrapQueryExpressionBodyInDerivedTable, + unionOrderBy, unionLimit + ); + } + finally { + context.qualify(qualify); + } } private final void toSQLOrderBy( diff --git a/jOOQ/src/main/java/org/jooq/impl/TableImpl.java b/jOOQ/src/main/java/org/jooq/impl/TableImpl.java index ad8dcb18e9..da1c975193 100644 --- a/jOOQ/src/main/java/org/jooq/impl/TableImpl.java +++ b/jOOQ/src/main/java/org/jooq/impl/TableImpl.java @@ -45,6 +45,7 @@ import static org.jooq.Clause.TABLE_ALIAS; import static org.jooq.Clause.TABLE_REFERENCE; import static org.jooq.SQLDialect.FIREBIRD; +import static org.jooq.SQLDialect.POSTGRES; import java.util.Arrays; @@ -132,7 +133,7 @@ public final void accept(Context ctx) { alias.accept(ctx); } else { - if (ctx.qualify()) { + if (ctx.qualify() && (ctx.family() != POSTGRES || parameters == null || ctx.declareTables())) { Schema mappedSchema = Utils.getMappedSchema(ctx.configuration(), getSchema()); if (mappedSchema != null) { diff --git a/jOOQ/src/test/java/org/jooq/test/BasicTest.java b/jOOQ/src/test/java/org/jooq/test/BasicTest.java index 2ed2fe7800..2d44eb7b4f 100644 --- a/jOOQ/src/test/java/org/jooq/test/BasicTest.java +++ b/jOOQ/src/test/java/org/jooq/test/BasicTest.java @@ -557,8 +557,8 @@ public void testRowValueExpressions() throws Exception { assertEquals(val("8"), t8.field8()); // Rendering - assertEquals("?", r_ref().render(t1)); - assertEquals("1", r_refI().render(t1)); + assertEquals("(?)", r_ref().render(t1)); + assertEquals("(1)", r_refI().render(t1)); assertEquals("(?, ?)", r_ref().render(t2)); assertEquals("(1, '2')", r_refI().render(t2)); assertEquals("(?, ?, ?)", r_ref().render(t3)); @@ -591,8 +591,8 @@ public void testRowValueExpressions() throws Exception { @Test public void testRowCompareConditions() throws Exception { - assertEquals("? = ?", r_ref().render(row(1).eq(row(1)))); - assertEquals("1 = 1", r_refI().render(row(1).eq(row(1)))); + assertEquals("(?) = (?)", r_ref().render(row(1).eq(row(1)))); + assertEquals("(1) = (1)", r_refI().render(row(1).eq(row(1)))); assertEquals("(?, ?) = (?, ?)", r_ref().render(row(1, "2").eq(row(1, "2")))); assertEquals("(1, '2') = (1, '2')", r_refI().render(row(1, "2").eq(row(1, "2")))); assertEquals("(?, ?, ?) = (?, ?, ?)", r_ref().render(row(1, "2", 3).eq(row(1, "2", 3)))); diff --git a/pom.xml b/pom.xml index ad1e6a913c..349f155587 100644 --- a/pom.xml +++ b/pom.xml @@ -12,7 +12,7 @@ org.jooq jooq-parent - 3.5.0 + 3.5.1 pom jOOQ Parent @@ -40,7 +40,7 @@ - 3.5.0 + 3.5.1