Closed joao-conde closed 4 days ago
I'm willing to pick this up if agreed upon.
There's nothing stopping you from using MariaDB features through the MySQL driver. If your application is trying to support both, I could see adding a flag or a getter to MySqlConnection
to return whether it's connected to a MySQL or a MariaDB database.
I don't see how adding a separate driver would make things easier. It'd require duplicate code paths or runtime checks either way.
Maybe I assumed to know the issue, and I'm wrong. I should perhaps open a bug one, but for example:
This code works with SQLITE:
pub async fn create_todo(pool: &SqlitePool, todo: CreateTodo) -> Result<Todo, InternalError> {
let todo = sqlx::query_as!(
Todo,
"INSERT INTO todos (title, description) VALUES (?, ?) RETURNING *",
todo.title,
todo.description
)
.fetch_one(pool)
.await?;
Ok(todo)
}
The same code wont work for a MySqlPool
. The error is ColumntNotFound("id")
. Ive tried explicitly enumerating the return columns too, no luck. This is using mariadb:11.4
and if I execute that same query on a mariadb client or through a terminal connection to the DB I get the correct return.
Are you using MySqlPool
connected to a MariaDB database?
Yup, docker image for mariadb:11.4
If you want ill open a bug issue and we close this one.
Feel free to open a bug.
Closing this in favor of https://github.com/launchbadge/sqlx/issues/3318
Is your feature request related to a problem? Please describe.
MYSQL and MARIADB are alike and the latter is supposed to be a drop-in replacement for the first, but not the other way around. By using the same driver for both mysql and mariadb users, we are limiting our ability to use some mariadb specific features.
Im frustrated by not being able to use features like
INSERT ... RETURNING *
.Describe the solution you'd like
Create a very similar driver for mariadb and add the new capabilities, starting with
RETURNING
:pDescribe alternatives you've considered
Swapping databases or performing an extra query to fetch the result, both unwanted.