Hi Deepankar,

Thanks a lot for your message. That's an interesting approach, I can see
how that works for you. The fact that you're implementing interfaces like
these (especially the one that is called QueryPartInternal) hints at there
being a feature request hidden in there somewhere. Things can break when
implementing internal interfaces. Besides, we'll "soon" seal the entire DSL
type hierarchy, because most attempts at implementing the DSL API (e.g.
Constraint) should also be considered tweaking internals and are usually
not the best way to achieve something.

I'd love to get a bit more context on your use-case here. It seems that you
would like to add some DDL clause support to your constraints when using
jOOQ's CREATE TABLE or ALTER TABLE support? Is it this feature you're
looking for?
https://github.com/jOOQ/jOOQ/issues/10363

Maybe, it's worth investigating also the option of supporting plain SQL
TableElement and CustomTableElement implementations, which allow for adding
arbitrary clauses to DDL statements, which jOOQ doesn't support (yet). I've
created a feature request for this:
https://github.com/jOOQ/jOOQ/issues/14807

Back to what broke here, the internal rendering API got changed a long time
ago with:
https://github.com/jOOQ/jOOQ/issues/3323

And the old internal API was removed with:
https://github.com/jOOQ/jOOQ/issues/11495

This change allows for traversing an expression tree only once to do both
actions in one go:
- SQL generation
- Bind value collection

In any case, I think you already correctly implemented the interfaces, with
your accept() method. You can now just remove the toSQL() and bind()
methods, which are no longer necessary.
Does that solve your problem?

Best Regards,
Lukas

On Thu, Mar 16, 2023 at 9:06 AM deepankar gupta <
[email protected]> wrote:

> Hi Lucas,
>
> I am trying to upgrade jooq version from 3.14.6 to 3.17.5. We have
> implemented 2 interfaces Constraint and QueryPartInternal. And also
> overridden toSQL(RenderContext ctx) and bind(BindContext ctx) methods but
> in jooq version 3.17.5 these methods are not there anymore. Need help on
> how these 2 methods implementation should look like in jooq version 3.17.5
>
> Code Snippet:
> private interface ConstraintInternal extends Constraint, QueryPartInternal
> {
>
>     }
>
> private Constraint useDeferrableConstraint(Constraint delegate){
>         return new ConstraintInternal() {
>
>             @Override
>             public void accept(Context<?> ctx) {
>                 ((QueryPartInternal) (delegate)).accept(ctx);
>                 if (join.from().isPartitioned()) {
>                     ctx.sql(" deferrable initially deferred not valid");
>                 } else {
>                     ctx.sql(" deferrable initially deferred");
>                 }
>             }
>
>             @Override
>             public boolean rendersContent(Context<?> ctx) {
>                 return  ((QueryPartInternal)
> (delegate)).rendersContent(ctx);
>             }
>
>             //Need help on this method(Not there anymore in jooq 3.17.5)
>             @Override
>             public void toSQL(RenderContext ctx) {
>                 ((QueryPartInternal) (delegate)).toSQL(ctx);
>             }
>
>             //Need help on this method(Not there anymore in jooq 3.17.5)
>             @Override
>             public void bind(BindContext ctx) throws DataAccessException {
>                 ((QueryPartInternal) (delegate)).bind(ctx);
>             }
>
>             @Override
>             public Clause[] clauses(Context<?> ctx) {
>                 return ((QueryPartInternal) (delegate)).clauses(ctx);
>             }
>
>             @Override
>             public boolean declaresFields() {
>                 return ((QueryPartInternal) (delegate)).declaresFields();
>             }
>
>             @Override
>             public boolean declaresTables() {
>                 return ((QueryPartInternal) (delegate)).declaresTables();
>             }
>
>             @Override
>             public boolean declaresWindows() {
>                 return  ((QueryPartInternal) (delegate)).declaresWindows();
>             }
>
>             @Override
>             public boolean declaresCTE() {
>                 return ((QueryPartInternal) (delegate)).declaresCTE();
>             }
>
>             //Need to override this method in jooq 3.17.5
>             @Override
>             public boolean declaresParameters() {
>                 return false;
>             }
>
>             @Override
>             public boolean generatesCast() {
>                 return ((QueryPartInternal) (delegate)).generatesCast();
>             }
>
>             @Override
>             public String getName() {
>                 return delegate.getName();
>             }
>
>             @Override
>             public Name getQualifiedName() {
>                 return delegate.getQualifiedName();
>             }
>
>             @Override
>             public Name getUnqualifiedName() {
>                 return delegate.getUnqualifiedName();
>             }
>
>             @Override
>             public String getComment() {
>                 return delegate.getComment();
>             }
>
>             @Override
>             public Comment getCommentPart() {
>                 return delegate.getCommentPart();
>             }
>
>             //Need to override this method in jooq 3.17.5
>             @Override
>             public @org.jetbrains.annotations.NotNull Name $name() {
>                 return delegate.$name();
>             }
>
>             @Override
>             public String toString() {
>                 if (join.from().isPartitioned()) {
>                     return delegate.toString() + " deferrable initially
> deferred not valid";
>                 } else {
>                     return delegate.toString() + " deferrable initially
> deferred";
>                 }
>             }
>
>             //Need to override this method in jooq 3.17.5
>             @Override
>             public <R> R $traverse(Traverser<?, R> traverser) {
>                 return delegate.$traverse(traverser);
>             }
>
>             //Need to override this method in jooq 3.17.5
>             @Override
>             public @org.jetbrains.annotations.NotNull QueryPart
> $replace(Replacer replacer) {
>                 return delegate.$replace(replacer);
>             }
>         };
>     }
>
> --
> 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].
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/jooq-user/71aaa0ae-71f0-450b-b3ec-db081635ddfen%40googlegroups.com
> <https://groups.google.com/d/msgid/jooq-user/71aaa0ae-71f0-450b-b3ec-db081635ddfen%40googlegroups.com?utm_medium=email&utm_source=footer>
> .
>

-- 
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].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/jooq-user/CAB4ELO5%2BJ%2BhxGRdm11qXNu8D7qSQLTuiGxEy%3DX7Dkrq_J8yWXg%40mail.gmail.com.

Reply via email to