[jOOQ/jOOQ#11196] Drop support for Java 6 and 7

- More IntelliJ inspections fixed
This commit is contained in:
Lukas Eder 2021-01-08 21:28:04 +01:00
parent ed9cf844f2
commit 54938152a9
33 changed files with 151 additions and 325 deletions

9
.gitignore vendored
View File

@ -1,4 +1,9 @@
/target
*.iml
.idea
.data/
# Include top level code styles and inspection profile
.idea/.*
.idea/*.xml
.idea/libraries
.data/
# Ignore project level .idea folders
*/.idea

View File

@ -358,10 +358,10 @@ public class MatcherStrategy extends DefaultGeneratorStrategy {
String result = null;
switch (mode) {
case DEFAULT: result = match(definition, embeddables.getExpression(), embeddables.getRecordImplements()); break;
case INTERFACE: result = match(definition, embeddables.getExpression(), embeddables.getInterfaceImplements()); break;
case POJO: result = match(definition, embeddables.getExpression(), embeddables.getPojoImplements()); break;
case RECORD: result = match(definition, embeddables.getExpression(), embeddables.getRecordImplements()); break;
case RECORD:
case DEFAULT: result = match(definition, embeddables.getExpression(), embeddables.getRecordImplements()); break;
}
if (result != null)
@ -421,10 +421,10 @@ public class MatcherStrategy extends DefaultGeneratorStrategy {
String result = null;
switch (mode) {
case DEFAULT: result = match(definition, embeddables.getExpression(), embeddables.getRecordClass()); break;
case INTERFACE: result = match(definition, embeddables.getExpression(), embeddables.getInterfaceClass()); break;
case POJO: result = match(definition, embeddables.getExpression(), embeddables.getPojoClass()); break;
case RECORD: result = match(definition, embeddables.getExpression(), embeddables.getRecordClass()); break;
case RECORD:
case DEFAULT: result = match(definition, embeddables.getExpression(), embeddables.getRecordClass()); break;
}
if (result != null)

View File

@ -105,7 +105,7 @@ public class JPADatabase extends AbstractInterpretingDatabase {
}
// [#9058] Properties use camelCase notation.
boolean useAttributeConverters = Boolean.valueOf(
boolean useAttributeConverters = Boolean.parseBoolean(
getProperties().getProperty("useAttributeConverters",
getProperties().getProperty("use-attribute-converters", "true")
)

View File

@ -101,7 +101,7 @@ public class LiquibaseDatabase extends AbstractInterpretingDatabase {
@Override
protected void export() throws Exception {
String scripts = getProperties().getProperty("scripts");
includeLiquibaseTables = Boolean.valueOf(getProperties().getProperty("includeLiquibaseTables", "false"));
includeLiquibaseTables = Boolean.parseBoolean(getProperties().getProperty("includeLiquibaseTables", "false"));
if (isBlank(scripts)) {
scripts = "";

View File

@ -82,7 +82,7 @@ public class BufferedLog implements Log {
case TRACE: delegate.trace(m.message, m.details, m.throwable); break;
case INFO: delegate.info (m.message, m.details, m.throwable); break;
case WARN: delegate.warn (m.message, m.details, m.throwable); break;
case ERROR: delegate.error(m.message, m.details, m.throwable); break;
case ERROR:
case FATAL: delegate.error(m.message, m.details, m.throwable); break;
}

View File

@ -240,7 +240,7 @@ public class DerbyDatabase extends AbstractDatabase implements ResultQueryDataba
if (split != null)
for (String index : split)
result.add(Integer.valueOf(index.trim()) - 1);
result.add(Integer.parseInt(index.trim()) - 1);
}
return result;

View File

@ -77,7 +77,7 @@ abstract class AbstractDataTypeX<T> extends AbstractDataType<T> {
@Override
public final DataType<T> nullability(Nullability n) {
return construct(precision0(), scale0(), length0(), n, collation(), characterSet(), n.nullable() ? false : identity(), defaultValue());
return construct(precision0(), scale0(), length0(), n, collation(), characterSet(), !n.nullable() && identity(), defaultValue());
}
@Override

View File

@ -161,7 +161,6 @@ abstract class AbstractQuery<R extends Record> extends AbstractFetchable<R> impl
* <p>
* {@inheritDoc}
*/
@SuppressWarnings("deprecation")
@Override
public Query bind(String param, Object value) {
Integer index = Ints.tryParse(param);
@ -188,7 +187,6 @@ abstract class AbstractQuery<R extends Record> extends AbstractFetchable<R> impl
* <p>
* {@inheritDoc}
*/
@SuppressWarnings("deprecation")
@Override
public Query bind(int index, Object value) {
Param<?>[] params = getParams().values().toArray(EMPTY_PARAM);

View File

@ -123,14 +123,6 @@ final class Alias<Q extends QueryPart> extends AbstractQueryPart {
this(wrapped, wrapping, alias, null, false);
}
Alias(Q wrapped, Q wrapping, Name alias, boolean wrapInParentheses) {
this(wrapped, wrapping, alias, null, wrapInParentheses);
}
Alias(Q wrapped, Q wrapping, Name alias, Name[] fieldAliases) {
this(wrapped, wrapping, alias, fieldAliases, false);
}
Alias(Q wrapped, Q wrapping, Name alias, Name[] fieldAliases, boolean wrapInParentheses) {
this.wrapped = wrapped;
this.wrapping = wrapping;

View File

@ -1742,11 +1742,6 @@ final class AlterTableImpl extends AbstractRowCountQuery implements
default:
ctx.visit(K_DROP);
break;

View File

@ -95,10 +95,6 @@ extends
case CUBRID:
case FIREBIRD:
case SQLITE:

View File

@ -116,7 +116,6 @@ import static org.jooq.impl.Tools.convertBytesToHex;
import static org.jooq.impl.Tools.getMappedUDTName;
import static org.jooq.impl.Tools.needsBackslashEscaping;
import static org.jooq.tools.StringUtils.leftPad;
import static org.jooq.tools.jdbc.JDBCUtils.safeClose;
import static org.jooq.tools.jdbc.JDBCUtils.safeFree;
import static org.jooq.tools.jdbc.JDBCUtils.wasNull;
import static org.jooq.tools.reflect.Reflect.on;
@ -1711,17 +1710,17 @@ public class DefaultBinding<T, U> implements Binding<T, U> {
@Override
final Boolean get0(BindingGetResultSetContext<U> ctx) throws SQLException {
return wasNull(ctx.resultSet(), Boolean.valueOf(ctx.resultSet().getBoolean(ctx.index())));
return wasNull(ctx.resultSet(), ctx.resultSet().getBoolean(ctx.index()));
}
@Override
final Boolean get0(BindingGetStatementContext<U> ctx) throws SQLException {
return wasNull(ctx.statement(), Boolean.valueOf(ctx.statement().getBoolean(ctx.index())));
return wasNull(ctx.statement(), ctx.statement().getBoolean(ctx.index()));
}
@Override
final Boolean get0(BindingGetSQLInputContext<U> ctx) throws SQLException {
return wasNull(ctx.input(), Boolean.valueOf(ctx.input().readBoolean()));
return wasNull(ctx.input(), ctx.input().readBoolean());
}
@Override
@ -1769,17 +1768,17 @@ public class DefaultBinding<T, U> implements Binding<T, U> {
@Override
final Byte get0(BindingGetResultSetContext<U> ctx) throws SQLException {
return wasNull(ctx.resultSet(), Byte.valueOf(ctx.resultSet().getByte(ctx.index())));
return wasNull(ctx.resultSet(), ctx.resultSet().getByte(ctx.index()));
}
@Override
final Byte get0(BindingGetStatementContext<U> ctx) throws SQLException {
return wasNull(ctx.statement(), Byte.valueOf(ctx.statement().getByte(ctx.index())));
return wasNull(ctx.statement(), ctx.statement().getByte(ctx.index()));
}
@Override
final Byte get0(BindingGetSQLInputContext<U> ctx) throws SQLException {
return wasNull(ctx.input(), Byte.valueOf(ctx.input().readByte()));
return wasNull(ctx.input(), ctx.input().readByte());
}
@Override
@ -2325,17 +2324,17 @@ public class DefaultBinding<T, U> implements Binding<T, U> {
@Override
final Double get0(BindingGetResultSetContext<U> ctx) throws SQLException {
return wasNull(ctx.resultSet(), Double.valueOf(ctx.resultSet().getDouble(ctx.index())));
return wasNull(ctx.resultSet(), ctx.resultSet().getDouble(ctx.index()));
}
@Override
final Double get0(BindingGetStatementContext<U> ctx) throws SQLException {
return wasNull(ctx.statement(), Double.valueOf(ctx.statement().getDouble(ctx.index())));
return wasNull(ctx.statement(), ctx.statement().getDouble(ctx.index()));
}
@Override
final Double get0(BindingGetSQLInputContext<U> ctx) throws SQLException {
return wasNull(ctx.input(), Double.valueOf(ctx.input().readDouble()));
return wasNull(ctx.input(), ctx.input().readDouble());
}
@Override
@ -2363,12 +2362,7 @@ public class DefaultBinding<T, U> implements Binding<T, U> {
@Override
final void sqlInline0(BindingSQLContext<U> ctx, EnumType value) throws SQLException {
String literal = value.getLiteral();
if (literal == null)
binding(VARCHAR).sql(new DefaultBindingSQLContext<>(ctx.configuration(), ctx.data(), ctx.render(), literal));
else
binding(VARCHAR).sql(new DefaultBindingSQLContext<>(ctx.configuration(), ctx.data(), ctx.render(), literal));
binding(VARCHAR).sql(new DefaultBindingSQLContext<>(ctx.configuration(), ctx.data(), ctx.render(), value.getLiteral()));
}
@Override
@ -2500,17 +2494,17 @@ public class DefaultBinding<T, U> implements Binding<T, U> {
@Override
final Float get0(BindingGetResultSetContext<U> ctx) throws SQLException {
return wasNull(ctx.resultSet(), Float.valueOf(ctx.resultSet().getFloat(ctx.index())));
return wasNull(ctx.resultSet(), ctx.resultSet().getFloat(ctx.index()));
}
@Override
final Float get0(BindingGetStatementContext<U> ctx) throws SQLException {
return wasNull(ctx.statement(), Float.valueOf(ctx.statement().getFloat(ctx.index())));
return wasNull(ctx.statement(), ctx.statement().getFloat(ctx.index()));
}
@Override
final Float get0(BindingGetSQLInputContext<U> ctx) throws SQLException {
return wasNull(ctx.input(), Float.valueOf(ctx.input().readFloat()));
return wasNull(ctx.input(), ctx.input().readFloat());
}
@Override
@ -2552,17 +2546,17 @@ public class DefaultBinding<T, U> implements Binding<T, U> {
@Override
final Integer get0(BindingGetResultSetContext<U> ctx) throws SQLException {
return wasNull(ctx.resultSet(), Integer.valueOf(ctx.resultSet().getInt(ctx.index())));
return wasNull(ctx.resultSet(), ctx.resultSet().getInt(ctx.index()));
}
@Override
final Integer get0(BindingGetStatementContext<U> ctx) throws SQLException {
return wasNull(ctx.statement(), Integer.valueOf(ctx.statement().getInt(ctx.index())));
return wasNull(ctx.statement(), ctx.statement().getInt(ctx.index()));
}
@Override
final Integer get0(BindingGetSQLInputContext<U> ctx) throws SQLException {
return wasNull(ctx.input(), Integer.valueOf(ctx.input().readInt()));
return wasNull(ctx.input(), ctx.input().readInt());
}
@Override
@ -2605,17 +2599,17 @@ public class DefaultBinding<T, U> implements Binding<T, U> {
@Override
final Long get0(BindingGetResultSetContext<U> ctx) throws SQLException {
return wasNull(ctx.resultSet(), Long.valueOf(ctx.resultSet().getLong(ctx.index())));
return wasNull(ctx.resultSet(), ctx.resultSet().getLong(ctx.index()));
}
@Override
final Long get0(BindingGetStatementContext<U> ctx) throws SQLException {
return wasNull(ctx.statement(), Long.valueOf(ctx.statement().getLong(ctx.index())));
return wasNull(ctx.statement(), ctx.statement().getLong(ctx.index()));
}
@Override
final Long get0(BindingGetSQLInputContext<U> ctx) throws SQLException {
return wasNull(ctx.input(), Long.valueOf(ctx.input().readLong()));
return wasNull(ctx.input(), ctx.input().readLong());
}
@Override
@ -2810,6 +2804,10 @@ public class DefaultBinding<T, U> implements Binding<T, U> {
SQLDialect family = ctx.family();
switch (family) {
// [#5895] HSQLDB derives the specific data type from the literal
case HSQLDB:
ctx.render().visit(K_TIMESTAMP).sql(" '").sql(escape(format(value, family), ctx.render())).sql('\'');
@ -2828,10 +2826,6 @@ public class DefaultBinding<T, U> implements Binding<T, U> {
// Some dialects implement SQL standard time literals
default:
ctx.render().visit(K_TIMESTAMP_WITH_TIME_ZONE).sql(" '").sql(escape(format(value, family), ctx.render())).sql('\'');
@ -3121,7 +3115,6 @@ public class DefaultBinding<T, U> implements Binding<T, U> {
*/
private static final long serialVersionUID = -1850495302106551527L;
@SuppressWarnings("unchecked")
private static final Converter<OffsetDateTime, Instant> CONVERTER = Converter.ofNullable(
OffsetDateTime.class,
Instant.class,
@ -3694,17 +3687,17 @@ public class DefaultBinding<T, U> implements Binding<T, U> {
@Override
final Short get0(BindingGetResultSetContext<U> ctx) throws SQLException {
return wasNull(ctx.resultSet(), Short.valueOf(ctx.resultSet().getShort(ctx.index())));
return wasNull(ctx.resultSet(), ctx.resultSet().getShort(ctx.index()));
}
@Override
final Short get0(BindingGetStatementContext<U> ctx) throws SQLException {
return wasNull(ctx.statement(), Short.valueOf(ctx.statement().getShort(ctx.index())));
return wasNull(ctx.statement(), ctx.statement().getShort(ctx.index()));
}
@Override
final Short get0(BindingGetSQLInputContext<U> ctx) throws SQLException {
return wasNull(ctx.input(), Short.valueOf(ctx.input().readShort()));
return wasNull(ctx.input(), ctx.input().readShort());
}
@Override

View File

@ -525,11 +525,7 @@ public class DefaultDSLContext extends AbstractScope implements DSLContext, Seri
@Override
public Map<String, Param<?>> extractParams(QueryPart part) {
return extractParams0(part, true);
}
final Map<String, Param<?>> extractParams0(QueryPart part, boolean includeInlinedParams) {
ParamCollector collector = new ParamCollector(configuration(), includeInlinedParams);
ParamCollector collector = new ParamCollector(configuration(), true);
collector.visit(part);
return Collections.unmodifiableMap(collector.resultFlat);
}

View File

@ -101,7 +101,7 @@ public class DefaultDataType<T> extends AbstractDataTypeX<T> {
* A pattern to be used to replace all precision, scale, and length
* information.
*/
private static final Pattern TYPE_NAME_PATTERN = Pattern.compile("\\([^\\)]*\\)");
private static final Pattern TYPE_NAME_PATTERN = Pattern.compile("\\([^)]*\\)");
// -------------------------------------------------------------------------
// Data type caches

View File

@ -649,10 +649,6 @@ class DefaultRenderContext extends AbstractContext<RenderContext> implements Ren

View File

@ -149,8 +149,7 @@ final class Diff {
// TODO: Can we reuse the logic from DROP_TABLE?
for (Table<?> t1 : s.getTables())
for (UniqueKey<?> uk : t1.getKeys())
for (ForeignKey<?, ?> fk : uk.getReferences())
r.droppedFks.add(fk);
r.droppedFks.addAll(uk.getReferences());
if (!StringUtils.isEmpty(s.getName()))
r.queries.add(ctx.dropSchema(s).cascade());
@ -428,10 +427,8 @@ final class Diff {
return false;
// [#10864] In most dialects, DECIMAL and NUMERIC are aliases and don't need to be changed into each other
else if (type1.getType() == BigDecimal.class && type2.getType() == BigDecimal.class)
return false;
else
return true;
return type1.getType() != BigDecimal.class || type2.getType() != BigDecimal.class;
}
private final boolean precisionDifference(DataType<?> type1, DataType<?> type2) {

View File

@ -139,12 +139,8 @@ implements
Field<T> outerField = outer.field(field);
Field<T> innerField = inner.field(field);
if (outerField == null || innerField == null) {
return;
}
else {
if (outerField != null && innerField != null)
selfJoin.addConditions(outerField.equal(innerField));
}
}
// ------------------------------------------------------------------------

View File

@ -54,7 +54,7 @@ final class FieldAlias<T> extends AbstractField<T> {
FieldAlias(Field<T> field, Name alias) {
super(alias, field.getDataType());
this.alias = new Alias<>(field, this, alias, false);
this.alias = new Alias<>(field, this, alias);
}
@Override

View File

@ -330,7 +330,7 @@ final class FieldMapsForInsert extends AbstractQueryPart {
Field<?> e = empty.get(f);
if (e == null) {
e = new LazyVal<>(null, (Field<Object>) f);
e = new LazyVal<>((Field<Object>) f);
empty.put(f, e);
}

View File

@ -107,13 +107,6 @@ final class ForLock extends AbstractQueryPart {
switch (forLockMode) {
case UPDATE:
ctx.formatSeparator()
.visit(K_FOR)
.sql(' ')
.visit(forLockMode.toKeyword());
break;
case SHARE:
if (NO_SUPPORT_STANDARD_FOR_SHARE.contains(ctx.dialect()))
ctx.formatSeparator()
@ -125,6 +118,7 @@ final class ForLock extends AbstractQueryPart {
.visit(forLockMode.toKeyword());
break;
case UPDATE:
case KEY_SHARE:
case NO_KEY_UPDATE:
default:

View File

@ -39,6 +39,7 @@ package org.jooq.impl;
import static java.util.Collections.emptyList;
import static java.util.Comparator.comparing;
import static java.util.Comparator.comparingInt;
import static org.jooq.impl.DSL.name;
import static org.jooq.impl.Tools.EMPTY_CHECK;
import static org.jooq.impl.Tools.EMPTY_SORTFIELD;
@ -160,7 +161,7 @@ final class InformationSchemaMetaImpl extends AbstractMeta {
Catalog catalog = catalogsByName.get(catalogName);
if (catalog == null) {
errors.add(String.format("Catalog " + catalogName + " not defined for schema " + xs.getSchemaName()));
errors.add("Catalog " + catalogName + " not defined for schema " + xs.getSchemaName());
continue schemaLoop;
}
@ -177,7 +178,7 @@ final class InformationSchemaMetaImpl extends AbstractMeta {
Schema schema = schemasByName.get(schemaName);
if (schema == null) {
errors.add(String.format("Schema " + schemaName + " not defined for domain " + d.getDomainName()));
errors.add("Schema " + schemaName + " not defined for domain " + d.getDomainName());
continue domainLoop;
}
@ -219,7 +220,7 @@ final class InformationSchemaMetaImpl extends AbstractMeta {
Schema schema = schemasByName.get(schemaName);
if (schema == null) {
errors.add(String.format("Schema " + schemaName + " not defined for table " + xt.getTableName()));
errors.add("Schema " + schemaName + " not defined for table " + xt.getTableName());
continue tableLoop;
}
@ -276,14 +277,14 @@ final class InformationSchemaMetaImpl extends AbstractMeta {
int length = xc.getCharacterMaximumLength() == null ? 0 : xc.getCharacterMaximumLength();
int precision = xc.getNumericPrecision() == null ? 0 : xc.getNumericPrecision();
int scale = xc.getNumericScale() == null ? 0 : xc.getNumericScale();
boolean nullable = xc.isIsNullable() == null ? true : xc.isIsNullable();
boolean nullable = xc.isIsNullable() == null || xc.isIsNullable();
// TODO: Exception handling should be moved inside SQLDataType
Name tableName = name(xc.getTableCatalog(), xc.getTableSchema(), xc.getTableName());
InformationSchemaTable table = tablesByName.get(tableName);
if (table == null) {
errors.add(String.format("Table " + tableName + " not defined for column " + xc.getColumnName()));
errors.add("Table " + tableName + " not defined for column " + xc.getColumnName());
continue columnLoop;
}
@ -299,12 +300,7 @@ final class InformationSchemaMetaImpl extends AbstractMeta {
// -------------------------------------------------------------------------------------------------------------
Map<Name, List<SortField<?>>> columnsByIndex = new HashMap<>();
List<IndexColumnUsage> indexColumnUsages = new ArrayList<>(meta.getIndexColumnUsages());
indexColumnUsages.sort((o1, o2) -> {
int p1 = o1.getOrdinalPosition();
int p2 = o2.getOrdinalPosition();
return (p1 < p2) ? -1 : ((p1 == p2) ? 0 : 1);
});
indexColumnUsages.sort(comparingInt(IndexColumnUsage::getOrdinalPosition));
indexColumnLoop:
for (IndexColumnUsage ic : indexColumnUsages) {
@ -315,14 +311,14 @@ final class InformationSchemaMetaImpl extends AbstractMeta {
InformationSchemaTable table = tablesByName.get(tableName);
if (table == null) {
errors.add(String.format("Table " + tableName + " not defined for index " + indexName));
errors.add("Table " + tableName + " not defined for index " + indexName);
continue indexColumnLoop;
}
TableField<Record, ?> field = (TableField<Record, ?>) table.field(ic.getColumnName());
if (field == null) {
errors.add(String.format("Column " + ic.getColumnName() + " not defined for table " + tableName));
errors.add("Column " + ic.getColumnName() + " not defined for table " + tableName);
continue indexColumnLoop;
}
@ -337,14 +333,14 @@ final class InformationSchemaMetaImpl extends AbstractMeta {
InformationSchemaTable table = tablesByName.get(tableName);
if (table == null) {
errors.add(String.format("Table " + tableName + " not defined for index " + indexName));
errors.add("Table " + tableName + " not defined for index " + indexName);
continue indexLoop;
}
List<SortField<?>> c = columnsByIndex.get(indexName);
if (c == null || c.isEmpty()) {
errors.add(String.format("No columns defined for index " + indexName));
errors.add("No columns defined for index " + indexName);
continue indexLoop;
}
@ -638,7 +634,7 @@ final class InformationSchemaMetaImpl extends AbstractMeta {
}
}
private final class InformationSchemaTable extends TableImpl<Record> {
private static final class InformationSchemaTable extends TableImpl<Record> {
/**
* Generated UID
@ -681,7 +677,7 @@ final class InformationSchemaMetaImpl extends AbstractMeta {
}
}
private final class InformationSchemaDomain<T> extends DomainImpl<T> {
private static final class InformationSchemaDomain<T> extends DomainImpl<T> {
/**
* Generated UID
@ -693,7 +689,7 @@ final class InformationSchemaMetaImpl extends AbstractMeta {
}
}
private final class InformationSchemaSequence<N extends Number> extends SequenceImpl<N> {
private static final class InformationSchemaSequence<N extends Number> extends SequenceImpl<N> {
/**
* Generated UID

View File

@ -107,7 +107,7 @@ import org.jooq.impl.ConstraintImpl.Action;
import org.jooq.tools.Convert;
import org.jooq.tools.JooqLogger;
@SuppressWarnings({ "rawtypes", "serial", "unchecked" })
@SuppressWarnings({ "rawtypes", "unchecked" })
final class Interpreter {
private static final JooqLogger log = JooqLogger.getLogger(Interpreter.class);
@ -695,7 +695,7 @@ final class Interpreter {
private final Iterable<Field<?>> assertFields(Query query, Iterable<FieldOrConstraint> fields) {
return () -> new Iterator<Field<?>>() {
Iterator<FieldOrConstraint> it = fields.iterator();
final Iterator<FieldOrConstraint> it = fields.iterator();
@Override
public boolean hasNext() {
@ -1190,8 +1190,7 @@ final class Interpreter {
for (MutableCatalog catalog : catalogs.values())
for (MutableSchema schema : catalog.schemas)
for (MutableTable table : schema.tables)
result.add(table);
result.addAll(schema.tables);
return result;
}
@ -1394,23 +1393,6 @@ final class Interpreter {
case DERBY:
case FIREBIRD:
case H2:
case HSQLDB:
case POSTGRES:
return InterpreterNameLookupCaseSensitivity.WHEN_QUOTED;
case MARIADB:
case MYSQL:

View File

@ -126,8 +126,8 @@ final class IsDistinctFrom<T> extends AbstractCondition {
// [#7222] [#7224] Make sure the columns are aliased
else if (EMULATE_DISTINCT_PREDICATE.contains(ctx.dialect()))
ctx.visit(comparator == IS_DISTINCT_FROM
? (QueryPartInternal) notExists(select(lhs.as("x")).intersect(select(rhs.as("x"))))
: (QueryPartInternal) exists(select(lhs.as("x")).intersect(select(rhs.as("x")))));
? notExists(select(lhs.as("x")).intersect(select(rhs.as("x"))))
: exists(select(lhs.as("x")).intersect(select(rhs.as("x")))));
// MySQL knows the <=> operator
else if (SUPPORT_DISTINCT_WITH_ARROW.contains(ctx.dialect()))

View File

@ -54,20 +54,18 @@ import org.jooq.conf.ParamType;
final class LazyVal<T> extends AbstractParamX<T> {
private static final long serialVersionUID = 1258437916133900173L;
private final T value;
private final Field<T> field;
private transient AbstractParamX<T> delegate;
LazyVal(T value, Field<T> field) {
super(AbstractParam.name(value, null), field.getDataType());
LazyVal(Field<T> field) {
super(Names.N_VALUE, field.getDataType());
this.value = value;
this.field = field;
}
private final void init() {
if (delegate == null)
delegate = (AbstractParamX<T>) DSL.val(value, field);
delegate = (AbstractParamX<T>) DSL.val(null, field);
}
// ------------------------------------------------------------------------
@ -96,7 +94,7 @@ final class LazyVal<T> extends AbstractParamX<T> {
@Override
public final T getValue() {
if (delegate == null)
return value;
return null;
init();
return delegate.getValue();

View File

@ -149,8 +149,8 @@ final class MetaDataFieldProvider implements Serializable {
// [#650, #667] All types should be known at this point, but in plain
// SQL environments, it is possible that user-defined types, or vendor-specific
// types (e.g. such as PostgreSQL's json type) will cause this exception.
catch (SQLDialectNotSupportedException ignore) {
log.debug("Not supported by dialect", ignore.getMessage());
catch (SQLDialectNotSupportedException e) {
log.debug("Not supported by dialect", e.getMessage());
}
fields[i - 1] = field(name, dataType);

View File

@ -360,20 +360,19 @@ final class MetaImpl extends AbstractMeta {
types = new String[] { "TABLE", "VIEW", "SYSTEM_TABLE", "SYSTEM_VIEW", "MATERIALIZED VIEW" };
break;
// [#2323] SQLite JDBC drivers have a bug. They return other
// object types, too: https://bitbucket.org/xerial/sqlite-jdbc/issue/68
case SQLITE:
types = new String[] { "TABLE", "VIEW" };
break;
/* [/pro] */
default:
types = null;

View File

@ -241,8 +241,7 @@ final class MigrationImpl extends AbstractScope implements Migration {
Set<Schema> set = new LinkedHashSet<>();
for (MigrationSchema schema : configuration.settings().getMigrationSchemata())
for (Schema s : lookup(asList(schema(name(schema.getCatalog(), schema.getSchema())))))
set.add(s);
set.addAll(lookup(asList(schema(name(schema.getCatalog(), schema.getSchema())))));
return set;
}

View File

@ -1621,9 +1621,8 @@ final class ParserContext {
else if (parseKeywordIf("GROUPING SETS")) {
List<List<Field<?>>> fieldSets = new ArrayList<>();
parse('(');
do {
do
fieldSets.add(parseFieldsOrEmptyParenthesised());
}
while (parseIf(','));
parse(')');
result.addGroupBy(groupingSets(fieldSets.toArray((Collection[]) EMPTY_COLLECTION)));
@ -1988,10 +1987,8 @@ final class ParserContext {
break valuesLoop;
List<Field<?>> values = new ArrayList<>();
do {
Field<?> value = parseKeywordIf("DEFAULT") ? default_() : parseField();
values.add(value);
}
do
values.add(parseKeywordIf("DEFAULT") ? default_() : parseField());
while (parseIf(','));
if (fields != null && fields.length != values.size())
@ -2244,10 +2241,8 @@ final class ParserContext {
parseKeyword("VALUES");
parse('(');
insertValues = new ArrayList<>();
do {
Field<?> value = parseKeywordIf("DEFAULT") ? default_() : parseField();
insertValues.add(value);
}
do
insertValues.add(parseKeywordIf("DEFAULT") ? default_() : parseField());
while (parseIf(','));
parse(')');
@ -3414,7 +3409,6 @@ final class ParserContext {
// -----------------------------------------------------------------------------------------------------------------
@ -4251,9 +4245,8 @@ final class ParserContext {
parse('(');
if (!parseIf(')')) {
do {
do
values.add(parseStringLiteral());
}
while (parseIf(','));
parse(')');
}
@ -4613,9 +4606,8 @@ final class ParserContext {
}
if (parseIf('(')) {
do {
do
parseAlterTableAddFieldsOrConstraints(list);
}
while (parseIf(','));
parse(')');
@ -4625,9 +4617,8 @@ final class ParserContext {
return parseAlterTableAddFieldFirstBeforeLast(s1.addColumnIfNotExists(parseAlterTableAddField(null)));
}
else {
do {
do
parseAlterTableAddFieldsOrConstraints(list);
}
while (parseIf(',') && (parseKeywordIf("ADD") || !peekKeyword("ALTER", "COMMENT", "DROP", "MODIFY", "OWNER TO", "RENAME")));
}
@ -5496,9 +5487,8 @@ final class ParserContext {
}
else {
fields = new ArrayList<>();
do {
do
fields.add(toField(parseConcat(null)));
}
while (parseIf(','));
parse(')');
}
@ -5522,9 +5512,8 @@ final class ParserContext {
}
else {
fields = new ArrayList<>();
do {
do
fields.add(toField(parseConcat(null)));
}
while (parseIf(','));
parse(')');
}
@ -5580,9 +5569,8 @@ final class ParserContext {
private final List<Table<?>> parseTables() {
List<Table<?>> result = new ArrayList<>();
do {
do
result.add(parseTable());
}
while (parseIf(','));
return result;
@ -5983,9 +5971,8 @@ final class ParserContext {
parseKeyword("VALUES");
List<Row> rows = new ArrayList<>();
do {
do
rows.add(parseTuple());
}
while (parseIf(','));
return values0(rows.toArray(EMPTY_ROW));
}
@ -6185,9 +6172,8 @@ final class ParserContext {
private final List<SortField<?>> parseSortSpecification() {
List<SortField<?>> result = new ArrayList<>();
do {
do
result.add(parseSortField());
}
while (parseIf(','));
return result;
}
@ -6226,18 +6212,16 @@ final class ParserContext {
private final List<Field<?>> parseFields() {
List<Field<?>> result = new ArrayList<>();
do {
do
result.add(parseField());
}
while (parseIf(','));
return result;
}
private final List<FieldOrRow> parseFieldsOrRows() {
List<FieldOrRow> result = new ArrayList<>();
do {
do
result.add(parseFieldOrRow());
}
while (parseIf(','));
return result;
}
@ -6261,9 +6245,8 @@ final class ParserContext {
private final List<Row> parseRows(Integer degree) {
List<Row> result = new ArrayList<>();
do {
do
result.add(parseRow(degree));
}
while (parseIf(','));
return result;
@ -7836,9 +7819,8 @@ final class ParserContext {
JSONNullType nullType = parseJSONNullTypeIf();
if (nullType == null) {
do {
do
result.add(parseJSONEntry());
}
while (parseIf(','));
nullType = parseJSONNullTypeIf();
@ -8290,7 +8272,6 @@ final class ParserContext {
Number second = null;
do {
boolean minus = parseIf('-');
if (!minus)
parseIf('+');
@ -10192,9 +10173,8 @@ final class ParserContext {
parse('(');
if (!parseIf(')')) {
do {
do
arguments.add(parseField());
}
while (parseIf(','));
parse(')');
@ -10223,9 +10203,8 @@ final class ParserContext {
private final List<Field<?>> parseFieldNames() {
List<Field<?>> result = new ArrayList<>();
do {
do
result.add(parseFieldName());
}
while (parseIf(','));
return result;
@ -10324,10 +10303,9 @@ final class ParserContext {
private final List<Name> parseIdentifiers() {
LinkedHashSet<Name> result = new LinkedHashSet<>();
do {
do
if (!result.add(parseIdentifier()))
throw exception("Duplicate identifier encountered");
}
while (parseIf(','));
return new ArrayList<>(result);
}

View File

@ -398,7 +398,6 @@ final class Tools {
* {@link Clause#FIELD_REFERENCE} may contain a
* {@link Clause#TABLE_REFERENCE}.
*/
@SuppressWarnings("javadoc")
DATA_OMIT_CLAUSE_EVENT_EMISSION,
/**
@ -410,7 +409,6 @@ final class Tools {
* practice should no longer be pursued, as such "sub-renderers" will emit /
* divert {@link Clause} events.
*/
@SuppressWarnings("javadoc")
DATA_WRAP_DERIVED_TABLES_IN_PARENTHESES,
@ -461,7 +459,6 @@ final class Tools {
/**
* [#3381] Omit the {@link Clause#SELECT_INTO}, as it is being emulated.
*/
@SuppressWarnings("javadoc")
DATA_OMIT_INTO_CLAUSE,
/**
@ -559,7 +556,6 @@ final class Tools {
/**
* [#3381] The table to be used for the {@link Clause#SELECT_INTO} clause.
*/
@SuppressWarnings("javadoc")
DATA_SELECT_INTO_TABLE,
/**
@ -604,7 +600,6 @@ final class Tools {
/**
@ -686,7 +681,7 @@ final class Tools {
final String key;
private DataCacheKey(String key) {
DataCacheKey(String key) {
this.key = key;
}
}
@ -1116,22 +1111,6 @@ final class Tools {
return result;
}
/**
* Get a converter from a {@link ConverterProvider} or <code>null</code> if
* no converter could be provided.
*/
static final <T, U> Converter<T, U> converter(Scope scope, Class<T> tType, Class<U> uType) {
return converter(configuration(scope), tType, uType);
}
/**
* Get a converter from a {@link ConverterProvider} or <code>null</code> if
* no converter could be provided.
*/
static final <T, U> Converter<T, U> converter(Attachable attachable, Class<T> tType, Class<U> uType) {
return converter(configuration(attachable), tType, uType);
}
/**
* Get a converter from a {@link ConverterProvider} or <code>null</code> if
* no converter could be provided.
@ -1381,18 +1360,6 @@ final class Tools {
return result;
}
static final Name[] unqualifiedNames(Field<?>[] fields) {
if (fields == null)
return null;
Name[] result = new Name[fields.length];
for (int i = 0; i < fields.length; i++)
result[i] = fields[i].getUnqualifiedName();
return result;
}
static final Field<?>[] unaliasedFields(Field<?>[] fields) {
if (fields == null)
return null;
@ -1929,7 +1896,6 @@ final class Tools {
return result;
}
@SuppressWarnings("serial")
static final <T> Field<T> inlined(final Field<T> field) {
return new CustomField<T>(field.getQualifiedName(), field.getDataType()) {
@Override
@ -2774,7 +2740,7 @@ final class Tools {
}
static final <T> T[] combine(T[] array, T value) {
T[] result = Arrays.copyOf(array, array.length + 1);;
T[] result = Arrays.copyOf(array, array.length + 1);
result[array.length] = value;
return result;
}
@ -3293,7 +3259,7 @@ final class Tools {
* the cached operation.
* @param operation The expensive operation.
* @param type The cache type to be used.
* @param keys The cache keys.
* @param key The cache keys.
* @return The cached value or the outcome of the cached operation.
*/
@SuppressWarnings("unchecked")
@ -3461,7 +3427,7 @@ final class Tools {
synchronized (initLock) {
if (ktJvmClassMapping == null) {
try {
ktJvmClassMapping = Reflect.on("kotlin.jvm.JvmClassMappingKt");
ktJvmClassMapping = Reflect.onClass("kotlin.jvm.JvmClassMappingKt");
}
catch (ReflectException ignore) {}
}
@ -3476,7 +3442,7 @@ final class Tools {
synchronized (initLock) {
if (ktKClasses == null) {
try {
ktKClasses = Reflect.on("kotlin.reflect.full.KClasses");
ktKClasses = Reflect.onClass("kotlin.reflect.full.KClasses");
}
catch (ReflectException ignore) {}
}
@ -3491,7 +3457,7 @@ final class Tools {
synchronized (initLock) {
if (ktKClass == null) {
try {
ktKClass = Reflect.on("kotlin.reflect.KClass");
ktKClass = Reflect.onClass("kotlin.reflect.KClass");
}
catch (ReflectException ignore) {}
}
@ -3506,7 +3472,7 @@ final class Tools {
synchronized (initLock) {
if (ktKTypeParameter == null) {
try {
ktKTypeParameter = Reflect.on("kotlin.reflect.KTypeParameter");
ktKTypeParameter = Reflect.onClass("kotlin.reflect.KTypeParameter");
}
catch (ReflectException ignore) {}
}
@ -3883,14 +3849,11 @@ final class Tools {
if ((method.getModifiers() & Modifier.STATIC) == 0)
result.add(method);
do {
do
for (Method method : type.getDeclaredMethods())
if ((method.getModifiers() & Modifier.STATIC) == 0)
result.add(method);
type = type.getSuperclass();
}
while (type != null);
while ((type = type.getSuperclass()) != null);
return result;
}
@ -3902,14 +3865,11 @@ final class Tools {
if ((field.getModifiers() & Modifier.STATIC) == 0)
result.add(field);
do {
do
for (java.lang.reflect.Field field : type.getDeclaredFields())
if ((field.getModifiers() & Modifier.STATIC) == 0)
result.add(field);
type = type.getSuperclass();
}
while (type != null);
while ((type = type.getSuperclass()) != null);
return result;
}
@ -3995,7 +3955,7 @@ final class Tools {
/**
* [#5666] Handle the complexity of each dialect's understanding of
* correctly calling {@link Statement#execute()}.
* correctly calling {@link PreparedStatement#execute()}}.
*/
static final SQLException executeStatementAndGetFirstResultSet(ExecuteContext ctx, int skipUpdateCounts) throws SQLException {
PreparedStatement stmt = ctx.statement();
@ -4119,7 +4079,7 @@ final class Tools {
*/
static final void consumeResultSets(ExecuteContext ctx, ExecuteListener listener, Results results, Intern intern, SQLException prev) throws SQLException {
boolean anyResults = false;
int i = 0;
int i;
int rows = (ctx.resultSet() == null) ? ctx.rows() : 0;
for (i = 0; i < maxConsumedResults; i++) {
@ -4546,16 +4506,6 @@ final class Tools {
@ -4605,6 +4555,7 @@ final class Tools {
case POSTGRES: {
begin(ctx);
break;
@ -4892,10 +4843,14 @@ final class Tools {
case CUBRID: ctx.sql(' ').visit(K_AUTO_INCREMENT); break;
case DERBY: ctx.sql(' ').visit(K_GENERATED_BY_DEFAULT_AS_IDENTITY); break;
case HSQLDB: ctx.sql(' ').visit(K_GENERATED_BY_DEFAULT_AS_IDENTITY).sql('(').visit(K_START_WITH).sql(" 1)"); break;
case SQLITE: ctx.sql(' ').visit(K_PRIMARY_KEY).sql(' ').visit(K_AUTOINCREMENT); break;
case POSTGRES:
@ -5229,7 +5184,6 @@ final class Tools {
return false;
}
@SuppressWarnings("serial")
static final QueryPartList<SelectFieldOrAsterisk> qualify(final Table<?> table, Iterable<SelectFieldOrAsterisk> fields) {
QueryPartList<SelectFieldOrAsterisk> result = new QueryPartList<SelectFieldOrAsterisk>() {
@Override
@ -5283,7 +5237,7 @@ final class Tools {
return ((SortFieldImpl<T>) sortField).getField();
}
static final <T> Field<?>[] fields(SortField<?>[] sortFields) {
static final Field<?>[] fields(SortField<?>[] sortFields) {
Field<?>[] result = new Field[sortFields.length];
for (int i = 0; i < result.length; i++)
@ -5808,19 +5762,6 @@ final class Tools {
case DERBY:
case FIREBIRD:
case H2:
case HSQLDB:
return ParseNameCase.UPPER_IF_UNQUOTED;
case MARIADB:
case MYSQL:

View File

@ -481,7 +481,7 @@ public final class JooqLogger implements Log {
case DEBUG: debug(message, details); break;
case INFO: info (message, details); break;
case WARN: warn (message, details); break;
case ERROR: error(message, details); break;
case ERROR:
case FATAL: error(message, details); break;
}
}
@ -515,7 +515,7 @@ public final class JooqLogger implements Log {
case DEBUG: debug(message, details, throwable); break;
case INFO: info (message, details, throwable); break;
case WARN: warn (message, details, throwable); break;
case ERROR: error(message, details, throwable); break;
case ERROR:
case FATAL: error(message, details, throwable); break;
}
}

View File

@ -552,8 +552,8 @@ public class JDBCUtils {
try {
blob.free();
}
catch (Exception ignore) {
log.warn("Error while freeing resource", ignore);
catch (Exception e) {
log.warn("Error while freeing resource", e);
}
// [#3069] The free() method was added only in JDBC 4.0 / Java 1.6
@ -572,8 +572,8 @@ public class JDBCUtils {
try {
clob.free();
}
catch (Exception ignore) {
log.warn("Error while freeing resource", ignore);
catch (Exception e) {
log.warn("Error while freeing resource", e);
}
// [#3069] The free() method was added only in JDBC 4.0 / Java 1.6
@ -592,8 +592,8 @@ public class JDBCUtils {
try {
xml.free();
}
catch (Exception ignore) {
log.warn("Error while freeing resource", ignore);
catch (Exception e) {
log.warn("Error while freeing resource", e);
}
// [#3069] The free() method was added only in JDBC 4.0 / Java 1.6
@ -612,8 +612,8 @@ public class JDBCUtils {
try {
array.free();
}
catch (Exception ignore) {
log.warn("Error while freeing resource", ignore);
catch (Exception e) {
log.warn("Error while freeing resource", e);
}
// [#3069] The free() method was added only in JDBC 4.0 / Java 1.6
@ -663,7 +663,7 @@ public class JDBCUtils {
* {@link SQLInput#wasNull()} is <code>true</code>
*/
public static final Boolean wasNull(SQLInput stream, Boolean value) throws SQLException {
return (value == null || (value.booleanValue() == false && stream.wasNull())) ? null : value;
return (value == null || (!value && stream.wasNull())) ? null : value;
}
/**
@ -708,7 +708,7 @@ public class JDBCUtils {
* {@link ResultSet#wasNull()} is <code>true</code>
*/
public static final Boolean wasNull(ResultSet rs, Boolean value) throws SQLException {
return (value == null || (value.booleanValue() == false && rs.wasNull())) ? null : value;
return (value == null || (!value && rs.wasNull())) ? null : value;
}
/**
@ -753,7 +753,7 @@ public class JDBCUtils {
* {@link CallableStatement#wasNull()} is <code>true</code>
*/
public static final Boolean wasNull(CallableStatement statement, Boolean value) throws SQLException {
return (value == null || (value.booleanValue() == false && statement.wasNull())) ? null : value;
return (value == null || (!value && statement.wasNull())) ? null : value;
}
/**

View File

@ -183,7 +183,7 @@ public final class DayToSecond extends Number implements Interval, Comparable<Da
// Accept also doubles as the number of milliseconds
try {
return valueOf(Double.valueOf(string));
return valueOf(Double.parseDouble(string));
}
catch (NumberFormatException e) {
DayToSecond result = dayToSecond(string);
@ -640,42 +640,24 @@ public final class DayToSecond extends Number implements Interval, Comparable<Da
@Override
public final int compareTo(DayToSecond that) {
if (days < that.days) {
if (days < that.days)
return -1;
}
if (days > that.days) {
else if (days > that.days)
return 1;
}
if (hours < that.hours) {
else if (hours < that.hours)
return -1;
}
if (hours > that.hours) {
else if (hours > that.hours)
return 1;
}
if (minutes < that.minutes) {
else if (minutes < that.minutes)
return -1;
}
if (minutes > that.minutes) {
else if (minutes > that.minutes)
return 1;
}
if (seconds < that.seconds) {
else if (seconds < that.seconds)
return -1;
}
if (seconds > that.seconds) {
else if (seconds > that.seconds)
return 1;
}
if (nano < that.nano) {
return -1;
}
if (nano > that.nano) {
return 1;
}
return 0;
else
return Integer.compare(nano, that.nano);
}
@Override

View File

@ -152,7 +152,7 @@ public final class YearToSecond extends Number implements Interval, Comparable<Y
// Accept also doubles as the number of milliseconds
try {
return valueOf(Double.valueOf(string));
return valueOf(Double.parseDouble(string));
}
catch (NumberFormatException e) {
Matcher matcher = PATTERN.matcher(string);
@ -314,14 +314,7 @@ public final class YearToSecond extends Number implements Interval, Comparable<Y
@Override
public final int compareTo(YearToSecond that) {
double i1 = doubleValue();
double i2 = that.doubleValue();
return i1 > i2
? 1
: i1 < i2
? -1
: 0;
return Double.compare(doubleValue(), that.doubleValue());
}
@Override