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]>:

> 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].
> 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