sqlx icon indicating copy to clipboard operation
sqlx copied to clipboard

Migrations fail with mariadb

Open lovasoa opened this issue 3 years ago • 2 comments

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

lovasoa avatar Sep 03 '22 12:09 lovasoa

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.

abonander avatar Sep 08 '22 22:09 abonander

I was getting this error because I did not provide the database in the connection URL.

ratnaraj7 avatar Apr 28 '24 19:04 ratnaraj7