Thanks Lukas! That's a pity... an issue open since 2012 doesn't sound encouraging :)
Would changing the constructor of TableImpl to use the logic from org.jooq.impl.Tools#aliased make it possible or it would violate the type safety? (In order to remove the extra wrapper created) On Wednesday, January 24, 2018 at 9:30:23 AM UTC+2, Lukas Eder wrote: > > Hi Victor, > > Indeed that would be great. There's a pending feature request to help make > this easier, but currently isn't possible in an easy way: > https://github.com/jOOQ/jOOQ/issues/1969 > > Thanks, > Lukas > > 2018-01-23 20:14 GMT+01:00 <[email protected] <javascript:>>: > >> I'm trying to find a way to implement a function that would return an >> instance of my custom table class (extending TableImpl) but containing a >> derived table inside. >> As a simplified example consider the following: >> class MyTable extends TableImpl<Record> { >> public MyTable() { >> super("my_table"); >> } >> MyTable(String alias, Table<Record> aliased) { >> super(ailas, null, aliased); >> } >> public final TableField<Record, Integer> f1 = createField("f1", >> SQLDataType.INTEGER); >> public final TableField<Record, String> f2 = createField("f2", >> SQLDataType.VARCHAR); >> } >> Suppose I now want to expose a "view" on this table - select * from >> my_table where f1 > 5 and present it to my clients as an instance of >> MyTable. >> I tried to >> Table<Record> derived = DSL.select().from(myTable).where(f1.ge >> (5)).asTable(); >> and then >> new MyTable("filtered", derived); >> but this doesn't render correctly in the final SQL. What what I managed >> to understand, asTable already produces an alias and then the constructor >> of TableImpl wraps it in another alias which results in losing the SQL >> of the derived table. >> >> Is this supposed to work? Am I doing something I'm not supposed to do >> with jOOQ? Is there another way to achieve this? I know I can do >> derived.field("f1"), but this is untyped and not nice. >> Thanks a lot! >> >> -- >> 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] <javascript:>. >> For more options, visit https://groups.google.com/d/optout. >> > > -- 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/d/optout.
