Open fwbrasil opened 8 years ago
Workaround You can build your application for each context to separate artefacts (jars) and make some supervisor process to stop application with one context and start with another. See https://gitter.im/getquill/quill?at=58498469c29531ac5d393595. Also this's useful for those who just want to build application for different environment like test and prod with different contexts.
I made an example project showing how to switch between MySQL and H2 JDBC contexts at compile-time. Do not forget to checkout quill-multiple-jdbc-contexts
branch.
If someone needs to switch between sync (e. g. H2JdbcContext
) and async (e. g. PostgresAsyncContext
) then take a look at this sample project (checkout quill-multiple-mixed-contexts
branch).
@getquill/maintainers I've been thinking about this feature but I couldn't find a good way to implement it. I think I'll remove it from the 2.0
plans. It's too complex and I don't see push from the community to have it. Wdyt?
I forgot to mention something. Even without this feature, users still can use multiple contexts using @mxl's approach or falling back to dynamic queries using https://github.com/getquill/quill/pull/886
@fwbrasil 👌 We receive questions about context switching on Gitter channel occasionally. But people usually ask about compile-time context switching which can be done by above workaround though it does not work in all cases (for example, when switching sync and async contexts). I think that fixing bugs is top priority now and this feature can wait.
any progress or plans to resolve this issue?
@getquill/maintainers I suggest to close this in favor of #971, since introducing multi-target sources should be avoided in favor of generating queries using idioms and io monad. Wdyt?
Version: (e.g.
0.6.0
) Module: (e.g.quill-core
)Problem
Quill doesn't provide an easy way to switch to a different SQL dialect at runtime. Queries are generated at compile time and the application needs to be recompiled in order to run on another target dialect.
Solution
Introduce multi-target sources, that generate queries against multiple compatible target sources at compile-time and allows the user to choose the target source type at runtime.
By "compatible" target sources I mean sources that have the exact same method signatures. For instance, it'd be possible to have a
but not
The macro would generate a message for all targets:
@getquill/maintainers