Skip to content

sea-orm-sync SQLite URI sqlx scheme causes DatabaseConnection error #2987

@thewenneur

Description

@thewenneur

Description

When a sqlite on disk database is open/created with the documentation’s sqlite://path/to/db.sqlite?mode=rwc URI format, the operation fails with an opaque "Connection Error: unable to open database file: path/to/db.sqlite?mode=rwc" error.
I assume the root cause is an API difference between sqlx and rusqlite drivers.

Steps to Reproduce

  1. create repo:
cargo new test-sea-orm-sync
cd .\test-sea-orm-sync\
cargo add sea-orm-sync@2.0.0-rc.36 -F rusqlite
cargo add rusqlite@0.37 -F bundled
  1. main.rs:
   // Naively follows documentation
 use sea_orm::*;
 
 fn main() {
   let _db: DatabaseConnection = Database::connect("sqlite://db.sqlite?mode=rwc").unwrap();
 }
test-sea-orm-sync> cargo r
    # ...
   Compiling sea-query-rusqlite v0.8.0-rc.15
   Compiling url v2.5.8
   Compiling sea-schema-sync v0.17.0-rc.15
   Compiling sea-orm-sync v2.0.0-rc.36
   Compiling test-sea-orm-sync v0.1.0 (...\test-sea-orm-sync)
    Finished `dev` profile [unoptimized + debuginfo] target(s) in 22.16s
     Running `target\debug\test-sea-orm-sync.exe`

thread 'main' (15132) panicked at src\main.rs:4:84:
called `Result::unwrap()` on an `Err` value: Conn(Rusqlite(SqliteFailure(Error { code: CannotOpen, extended_code: 14 }, Some("unable to open database file: db.sqlite?mode=rwc"))))
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
error: process didn't exit successfully: `target\debug\test-sea-orm-sync.exe` (exit code: 101)

Expected Behavior

Creation/Opening of a database named db.sqlite.

Actual Behavior

Couldn't create/open the database.

Reproduces How Often

Always.

Workarounds

remove the trailing authorization in URI:

  use sea_orm::*;
  
  fn main() {
    let _db: DatabaseConnection = Database::connect("sqlite://db.sqlite").unwrap();
  }

Versions

OS: Windows 11.
Database SQLite bundled.
The output of cargo tree | grep sea- from the console:

test-sea-orm-sync v0.1.0 (...\test-sea-orm-sync)
└── sea-orm-sync v2.0.0-rc.36
    ├── sea-orm-macros v2.0.0-rc.36 (proc-macro)
    │   ├── sea-bae v0.2.1 (proc-macro)
    ├── sea-query v1.0.0-rc.31
    │   ├── sea-query-derive v1.0.0-rc.12 (proc-macro)
    ├── sea-query-rusqlite v0.8.0-rc.15
    │   └── sea-query v1.0.0-rc.31 (*)
    ├── sea-schema-sync v0.17.0-rc.15
    │   ├── sea-query v1.0.0-rc.31 (*)
    │   ├── sea-query-rusqlite v0.8.0-rc.15 (*)
    │   └── sea-schema-derive v0.3.0 (proc-macro)

Metadata

Metadata

Assignees

No one assigned

    Type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions