Hi Lukas,

Thank you for your answer, I get it now why an alias sometimes shouldn't 
have a reference to a table: even considering that some expression like 
"'myvar' as myvar" is in context of some table, it is not really related to 
the table by its nature.

I think I'll go with keeping a reference to the original field - it is 
already kind of what I'm already doing.

Also it's nice to see that a lot of cases already have corresponding issues 
on GitHub :)

On Monday, November 20, 2017 at 1:31:00 PM UTC+2, Lukas Eder wrote:
>
> Hello,
>
> There currently isn't such a public API. There's a pending feature request 
> to help discover such things:
> https://github.com/jOOQ/jOOQ/issues/2579
>
> But I'm currently not sure if opening up such API is a good idea - it's 
> hard to keep the internal QueryPart APIs backwards compatible. Also, an 
> aliased field is quite a different thing from the original field reference. 
> For one, it can alias anything, including expressions based on several 
> field references and other expressions, such as:
>
> first_name || ' ' || last_name AS name
>
>
> Of course, you can keep a reference to your unaliased field and fetch the 
> qualified name from that:
>
> Field<?> original = field( name( "MyTable", "myField" ) );
> Field<?> aliased = original.as( "myAlias" );
> String tableName = original.getQualifiedName().qualifier().last();
>
>
> But I suspect the logic creating the alias is disconnected from the logic 
> referencing it.
>
> As another workaround, you can use reflection on jOOQ's internals.
>
> A third workaround would be to traverse the expression tree using a 
> VisitListener and introspect the individual parts being traversed...
>
> I hope this helps,
> Lukas
>
> 2017-11-17 17:20 GMT+01:00 <[email protected] <javascript:>>:
>
>> Is it possible to get the table name from a field constructed as the 
>> following?
>> field( name( "MyTable", "myField" ) ).as( "myAlias" )
>>
>> When I try to get it through .getQualifiedName() it returns only the 
>> alias part, without a table name.
>>
>> -- 
>> 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.

Reply via email to