Add support for shared-schema multi-tenancy #2682
With the implementation of #2665, jOOQ can implement shared-schema multi-tenancy out of the box - similar to the pre-existing separate-schema / separate-table multi-tenancy, which is currently implemented through schema-mapping and table-mapping.
However, it is very difficult to get
-- Input SQL using multi-tenant table t, and single-tenant table u SELECT t.a, u.b FROM t, u UPDATE t SET t.a = ? WHERE t.b IN (SELECT b FROM u) -- Output SQL in databases supporting updatable views SELECT t.a, u.b FROM (SELECT * FROM t WHERE t.tenant = ?) AS t, u UPDATE (SELECT * FROM t WHERE t.tenant = ?) SET t.a = ? WHERE t.b IN (SELECT b FROM u) -- Output SQL in databases not supporting updatable views SELECT t.a, u.b FROM t, u WHERE t.tenant = ? UPDATE t SET t.a = ? WHERE t.b IN (SELECT b FROM u) AND t.tenant = ?
More insight can be seen in this interesting MSDN documentation page:
This was also requested in this thread here:
And in this discussion here:
@Zynde: jOOQ doesn't support it out of the box, but you might be able to roll your own:
I'm not aware of such a feature in PostgreSQL thus far, unlike Oracle or SQL Server. You might be able to emulate it, however, using views and PL/PERL global variables, similar to Oracle's