Thanks for your message. That appears to be a bug. Can you please create an
issue here: https://github.com/jOOQ/jOOQ/issues/new/choose

On Wed, May 10, 2023 at 4:14 PM Fabio Cechinel Veronez <
fabio.vero...@gmail.com> wrote:

> Hi,
>
> I have a question regarding ExecuteListener's fetchEnd hook method, more
> specifically about the data available in the ExecuteContext instance it
> receives.
>
> According to `fetchEnd`'s Javadoc [1] the `ExecuteContext.query()` method
> returns
>
> > The `Query` object, if a jOOQ query is being executed or `null` otherwise
>
> However that appears not to be the case for some types of Queries. From
> what I could observer DML queries with RETURNING clauses won't be present
> in `ExecuteContext.query()`. I'm not sure whether it's the expected /
> designed behaviour or it's a bug.
>
> For example, let say I have a (dummy) ExecuteListener configured as follow
> (in Kotlin):
>
> ```
> configuration.setExecuteListener(
>     ExecuteListener.onFetchEnd { ctx ->
>         println("fetchEnd(query: ${ctx.query()})")
>     }
> )
> ```
>
> A simple table structure as:
>
> ```
> CREATE TABLE test (i INT);
> ```
>
> And a test code like:
>
> ```
> val testTable: Table<*> = DSL.table(DSL.name("test"))
> val field = DSL.field("i", Int::class.java)
>
> val rq1: ResultQuery<*> = ctx.selectFrom(testTable)
> val result1: Result<*> = rq1.fetch()
> assertEquals(listOf(1, 2, 3), result1.map { it.get(field) })
>
> val rq2: ResultQuery<*> = ctx.update(testTable).set(field,
> 3).returning(field)
> val result2: Result<*> = rq2.fetch()
> assertEquals(listOf(3, 3, 3), result2.map { it.get(field) })
>
> val rq3: ResultQuery<*> = ctx.resultQuery("UPDATE test SET i = 4 RETURNING
> *")
> val result3: Result<*> = rq3.fetch()
> assertEquals(listOf(4, 4, 4), result3.map { it.get(field) })
> ```
>
> When I run the test the ExecuteContext instance will only contain the
> Query for the execution of `rq1` and `rq3` and not for `rq2`. It will then
> print
>
> > fetchEnd(query: select *
> > from "test")
> > fetchEnd(query: null)
> > fetchEnd(query: UPDATE test SET i = 4 RETURNING *)
>
> It this difference on the behaviour of ExecuteListener's fetchEnd method
> expected or is it a bug?
>
> Thanks in advance.
>
> [1]:
> https://www.jooq.org/javadoc/3.17.12/org.jooq/org/jooq/ExecuteListener.html#fetchStart(org.jooq.ExecuteContext)
>
> --
> 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 jooq-user+unsubscr...@googlegroups.com.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/jooq-user/fb60205f-1de2-4b06-9da8-14a51f34fe71n%40googlegroups.com
> <https://groups.google.com/d/msgid/jooq-user/fb60205f-1de2-4b06-9da8-14a51f34fe71n%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 jooq-user+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/jooq-user/CAB4ELO7X%2BNt7%2BHNOmrtJhknJa_7sjS5CVrCx1RpMhHa8WmDs7g%40mail.gmail.com.

Reply via email to