New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Prevent or improve error message when mixing drivers #670
Comments
related to #48 |
What's the best option for dealing with this? I am writing my app against Postgres, but trying to use H2 for the tests, using the PostgresQL mode. I receive the error referenced in the mailing list thread. |
Make sure you import the same driver when defining your table and where you run queries (i.e. where you use |
I'm using the play-slick plugin, so I am not explicitly defining a driver outside my configuration. I am not sure how to extend the Tables trait in this case. I can provide code, if needed. |
BTW, I did some work on this recently in https://github.com/slick/slick/tree/tmp/scalatypes-in-drivers. It needs to be rebased on top of the fast path converters work and I'm not sure if it's the right direction in general, but it would solve this issue. |
@david-wilson if you provide code that reproduces the issue for you, I can take a look |
Another instance: #744 |
No, #744 is about using the wrong driver for a database. There's no (cheap, non-hacky) way to prevent this. |
He creates a column, which comes from a Table, which comes from a driver. Invoker or else could check that you run a query against the same driver you used to define it and throw a useful exception if not. Doesn't seem hacky to me. Am I missing something? |
But that is the case there, everything is run with H2Driver, just the database connection and JDBC driver is for Postgres. |
Ok, not the exact problem, but related. Mixing wrong combinations of Slick and JdbcDrivers. We could emit a warning (that can be disabled) if somebody doesn't use the jdbc driver we expect, or even better pick the right jdbc driver by default and let people override it. In almost all cases people use exactly the same driver (or 1 out of 2 in case of sqlserver). Better than failing with weird behavior like #744. |
No, we couldn't, because in real world applications we don't even see the driver. The Connection comes from a pool. |
good point... mh... on the other hand, people stumble over these problems when trying slick, which is not a "real world application" but an important use case for Slick adoption. So I still think this check makes sense. |
Another instance where somebody had problems with configuring the Slick driver together with the corresponding jdbc driver. https://groups.google.com/d/msgid/scalaquery/b07a1215-768a-4638-8050-3561dca4c4ba%40googlegroups.com We should really pick a default jdbc driver for a slick driver in my eyes! |
Maybe the slick drivers could provide shorthand Database factories, that
|
I wouldn't want to provide such methods unless we add connection pooling out of the box. We shouldn't encourage users not to use a connection pool. |
Another instance where subtle mixing up drivers lead to a lot of confusion: #794 |
Related to #419 |
As pointed out in #801, this looks like a bug in play-slick. You're supposed to use the injected singleton driver there, and if you do that consistently, none of these problems should occur. |
It seems to happen every once in a while that people accidentally use different Slick drivers for defining their table classes and for running queries, especially when using different databases in development, testing and production.
Here is one of several instances from the mailing list: https://groups.google.com/forum/#!searchin/scalaquery/TypeInfo/scalaquery/8zghyUwEONo/-GMkrE2Xm8gJ
We should either prevent this problem statically or at least throw a better error message.
The text was updated successfully, but these errors were encountered: