@Override public ColumnExpressions<?> booleanConstantValue(ConstantValue.BooleanConstant val, Void in) throws TypedValueVisitorException { return ColumnExpressions.singleColumn(new SimpleRowReader<Boolean>(), DSL.val(val.val)); }
@Override public ColumnExpressions<?> stringConstantValue(ConstantValue.StringConstant val, Void in) throws TypedValueVisitorException { return ColumnExpressions.singleColumn(new SimpleRowReader<String>(), DSL.val(val.val)); }
@Override public ColumnExpressions<?> integerConstantValue(ConstantValue.IntegerConstant val, Void in) throws TypedValueVisitorException { return ColumnExpressions.singleColumn(new SimpleRowReader<Integer>(), DSL.val(val.val)); }
@Override public ColumnExpressions<?> handleArg(int argIndex, Type argType) throws TypedValueVisitorException { if (argIndex < numLambdaCapturedArgs) { // Currently, we only support parameters of a few small simple types. // We should also support more complex types (e.g. entities) and allow // fields/methods of those entities to be called in the query (code // motion will be used to push those field accesses or method calls // outside the query where they will be evaluated and then passed in // as a parameter) if (!ALLOWED_QUERY_PARAMETER_TYPES.contains(argType)) throw new TypedValueVisitorException("Accessing a field with unhandled type"); return ColumnExpressions.singleColumn(new SimpleRowReader<>(), DSL.val(lambda.getCapturedArg(argIndex))); } else { Table<?> table = fromList.get(argIndex - numLambdaCapturedArgs); // TODO: Should this return a single column or all the columns of the table? ColumnExpressions<?> columns = new ColumnExpressions<>(new TableRowReader<>(table)); for (Field<?> field: table.fields()) columns.columns.add(field); return columns; } }
/** * Get a bind value. * * @see #val(Object) */ @Support public static Param<UByte> val(UByte value) { return val((Object) value, SQLDataType.TINYINTUNSIGNED); }
/** * Get a bind value. * * @see #val(Object) */ @Support public static Param<UShort> val(UShort value) { return val((Object) value, SQLDataType.SMALLINTUNSIGNED); }
/** * Get a bind value. * * @see #val(Object) */ @Support public static Param<Float> val(Float value) { return val((Object) value, SQLDataType.REAL); }
/** * Get a bind value. * * @see #val(Object) */ @Support public static Param<Boolean> val(Boolean value) { return val((Object) value, SQLDataType.BOOLEAN); }
/** * Get a bind value. * * @see #val(Object) */ @Support public static Param<String> val(String value) { return val((Object) value, SQLDataType.VARCHAR); }
/** * Get a bind value. * * @see #val(Object) */ @Support public static Param<Time> val(Time value) { return val((Object) value, SQLDataType.TIME); }
/** * A synonym for {@link #val(Object, Class)} to be used in Scala and Groovy, where * <code>val</code> is a reserved keyword. * * @see #val(Object, Class) */ @Support public static <T> Param<T> value(Object value, Class<T> type) { return val(value, type); }
/** * Get a bind value. * * @see #val(Object) */ @Support public static Param<UInteger> val(UInteger value) { return val((Object) value, SQLDataType.INTEGERUNSIGNED); }
/** * Get a bind value. * * @see #val(Object) */ @Support public static Param<byte[]> val(byte[] value) { return val((Object) value, SQLDataType.VARBINARY); }
/** * Get a bind value. * * @see #val(Object) */ @Support public static Param<Date> val(Date value) { return val((Object) value, SQLDataType.DATE); }
/** * Get a bind value. * * @see #val(Object) */ @Support public static Param<LocalDateTime> val(LocalDateTime value) { return val((Object) value, SQLDataType.LOCALDATETIME); }
/** * Get a bind value. * * @see #val(Object) */ @Support public static Param<OffsetDateTime> val(OffsetDateTime value) { return val((Object) value, SQLDataType.OFFSETDATETIME); }
@SuppressWarnings({ "unchecked", "rawtypes" }) @Override public final Field<T> bitNand(T value) { // Workaround assignment for https://bugs.eclipse.org/bugs/show_bug.cgi?id=473657 final Field result = DSL.bitNand((Field) this, (Field) val(value, this)); return result; }
protected final void setField(Parameter<?> parameter, Field<?> value) { // Be sure null is correctly represented as a null field if (value == null) { setField(parameter, val(null, parameter.getDataType())); } // [#1183] [#3533] Add the field to the in-values and mark them as non-defaulted else { inValues.put(parameter, value); inValuesDefaulted.remove(parameter); inValuesNonDefaulted.add(parameter); } }
@Override @Deprecated public final BindContext bindValue(Object value, Class<?> type) { try { return bindValue0(value, DSL.val(value, type)); } catch (SQLException e) { throw Tools.translate(null, e); } }
protected final void addInParameter(Parameter<?> parameter) { addParameter(parameter); inParameters.add(parameter); // IN parameters are initialised with null by default inValues.put(parameter, val(null, parameter.getDataType())); // [#1183] [#3533] defaulted parameters are marked as such if (parameter.isDefaulted()) inValuesDefaulted.add(parameter); else inValuesNonDefaulted.add(parameter); }