Open lovasoa opened 1 year ago
AnyKind
should have been deleted as sqlx-core
no longer has hardcoded knowledge of the exact set of drivers that are available. This is to allow our planned SQLx Pro offering to inject additional drivers without sqlx-core
needing to know about them.
AnyConnectOptions
exposes the database URL: https://docs.rs/sqlx/latest/sqlx/any/struct.AnyConnectOptions.html#structfield.database_url
You can match on the .scheme()
using Database::URL_SCHEMES
: https://docs.rs/sqlx/latest/sqlx/trait.Database.html#associatedconstant.URL_SCHEMES
I understand the need to monetize, but this makes the developer experience significantly worse for no added benefit :disappointed: And there isn't a single scheme string for each database to easily match against.
Maybe we could reinstate the kind method and the AnyKind enum (avoiding a new breaking change to delete it), and just add an Other(String)
variant to it, to make it possible to support arbitrary additional runtime drivers ?
This feedback would have been much more actionable during the nearly six months that 0.7 was in alpha.
Yes, I understand how annoying it must be to get this feedback now.
I did quickly try 0.7 before, but seeing how many updates it required in client code, I decided not to invest time in it, prioritizing other things that added more value to my project.
Another solution is to use AnyConnection
.backend_name()
https://docs.rs/sqlx/latest/sqlx/struct.AnyConnection.html#method.backend_name which only returns &str. For sqlx provided database driver they are equal to Database::NAME
const https://docs.rs/sqlx/latest/sqlx/trait.Database.html#associatedconstant.NAME. I was also facing same issue so I decided to use backend name &str to determine database type. You can easily create AnyConnection
from AnyConnectOptions
Thanks, that sounds useful ! However, that requires opening an actual connection to the database, right?
Yes, It requires opening actual connection to database. I am using connection later so I have no issue.
This does not enchant me, but I forked sqlx 0.6 as sqlx-oldapi
, and updated all dependencies, in order to be able to keep using the sqlx 0.6 API safely without deprecated subdependencies.
Hi ! I use sqlx in sqlpage, and was trying out sqlx v0.7, but I'm running into errors.
It is not mentioned in the changelog, but it looks like
AnyKind
is now the empty enum, andAnyConnectOptions
has lost itskind
method.Given an AnyConnectOptions, how do I now which database driver it will use ?