sqlx
sqlx copied to clipboard
Migrations fail with mariadb
Bug Description
When running an empty migration set against a fresh mariadb database, one gets the following error:
while executing migrations: error occurred while decoding column 0: unexpected null; try decoding as an `Option`
Minimal Reproduction
let opts: AnyConnectOptions = "mariadb://root:secret@localhost".parse()?;
let db = AnyPool::connect_with(opts).await?;
let migrator = Migrator::new(some_empty_dir).await?;
migrator.run(&db).await?;
Info
- SQLx version: 0.6.1
- SQLx features enabled: any, mysql
- Database server and version: mariadb:latest
- Operating system: linux
I'm not sure what query would be failing here. Ostensibly it would be in this file: https://github.com/launchbadge/sqlx/blob/main/sqlx-core/src/mysql/migrate.rs
However, at a glance I don't see how any queries in that file could produce this error. An unexpected null on an empty set sounds like a misuse of an aggregate function but I don't see any in there.
I was getting this error because I did not provide the database in the connection URL.