On Tue, Feb 18, 2014 at 10:37 AM, Ben Hood <[email protected]> wrote:
> I forgot to mention that one of the ways you could emulate this is to
> programmatically patch the fields from the object in this example
> called ranked and then supply the patched list back to the fluent API:
>
> List<Field> patched = patchRanked(ranked); // custom function to patch a list
>
> ctx.select(patched).from(ranked).where(RANK.le(10));
>
> In this light, having some kind of lambda support would make this code
> less verbose, but the main value add is that you could factor this in
> Java as well.
So I ended up hacking up something like this:
ctx.select(patch(ranked.fields(), EXCEL_FIELD)).from(ranked).where(RANK.le(n));
static Field[] patch(Field[] fields, Field ... fieldsToPatch) {
LinkedHashMap<String, Field> patched = new LinkedHashMap<String, Field>();
for (Field field : fields) {
patched.put(field.getName(), field);
}
for (Field patchField : fieldsToPatch) {
Field original = patched.get(patchField.getName());
patched.put(patchField.getName(),
DSL.field("concat('=\"',{0},'\"')", String.class,
original).as(patchField.getName()));
}
return patched.values().toArray(new Field[]{});
}
Not quite sure whether it's such a good idea though.
--
You received this message because you are subscribed to the Google Groups "jOOQ
User Group" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
For more options, visit https://groups.google.com/groups/opt_out.