Thanks!

It seems that VisitListener is indeed the way to go. 

It seems that Clauses will get removed at some point, so would it be best 
to do the same inference using QueryPart-subinterfaces?

I'll also take a look into the replacement API.

Direct support sounds great but I guess it's somewhere a bit further in the 
future?

torstai 10. elokuuta 2023 klo 11.02.45 UTC+3 lukas...@gmail.com kirjoitti:

> Hi Jarkko,
>
> Thanks for your message. A future version of jOOQ will support shared 
> schema multi tenancy out of the box:
> https://github.com/jOOQ/jOOQ/issues/2682
>
> It will be based on the new experimental replacement API:
>
> https://www.jooq.org/doc/latest/manual/sql-building/model-api/model-api-replacement/
>
> You can already build your own implementation based on the above (though 
> note it's experimental, so there are still some missing features (e.g. no 
> support for unions) and slight risk of breaking changes).
>
> You can also use a VisitListener, of course, or combine the two 
> approaches. There's a high-level example in this blog post showing how to 
> do this with a VisitListener:
>
> https://blog.jooq.org/implementing-client-side-row-level-security-with-jooq/
>
> Though, with the replacement API, it will be much simpler.
>
> I hope this helps,
> Lukas
>
> On Thu, Aug 10, 2023 at 9:22 AM Jarkko Miettinen <eon...@gmail.com> wrote:
>
>> Hi,
>>
>> I am planning to transform an existing piece of software using jOOQ to 
>> support multi-tenant data. As tenants share some data, multiple databases 
>> or schemas seem to make things very hard.
>>
>> So next idea is to use a discriminator column (tenant_id) in tables that 
>> have tenant-dependent data.
>>
>> I thought I could use VisitListener to rewrite queries to contain a 
>> where-clause limiting such queries into only one tenant (basically, add 
>> where tenant_id = ?).
>>
>> Is this doable in theory? In practice?
>>
>> To me, at least doable in theory seems correct as I'll get to visit all 
>> parts of the query.
>>
>> But as I did not find anyone having done that, in practice seems less 
>> certain.
>>
>> Is this a silly approach?
>>
>> -- 
>> 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+...@googlegroups.com.
>> To view this discussion on the web visit 
>> https://groups.google.com/d/msgid/jooq-user/59c1d6d3-0dcc-4a7e-94b1-37a7cf872d39n%40googlegroups.com
>>  
>> <https://groups.google.com/d/msgid/jooq-user/59c1d6d3-0dcc-4a7e-94b1-37a7cf872d39n%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/fbfee3bd-a5dc-4658-ac11-c74227c3fb9bn%40googlegroups.com.

Reply via email to