exqlite icon indicating copy to clipboard operation
exqlite copied to clipboard

Possible bug opening a database with an accent in path

Open jfburdet opened this issue 1 year ago • 1 comments

Hi, The following code is crashing when the directory containing the database contains accents. I'm not skilled enough to check if the bug is in exqlite code ou kino_db. I apologize in advance if I didn't open the bug in the right project.

Mix.install([
  {:kino_db, "~> 0.2.3"},
  {:exqlite, "~> 0.11"}
])

defmodule M do
  def create_and_open_db(path) do
    File.rmdir(path)
    File.mkdir(path)

    db_path = path <> "/database.db"

    System.cmd("sqlite3", [db_path, ".version"])

    opts = [database: db_path]
    {:ok, conn} = Kino.start_child({Exqlite, opts})

    Exqlite.query!(conn, "PRAGMA table_list", []) |> dbg()
  end
end

# Sucess
M.create_and_open_db("./no_accent")

# Failure
M.create_and_open_db("./répertoire_accentué")
``

jfburdet avatar Jan 30 '24 14:01 jfburdet

Oh this is interesting, I'll need to dig into it a little bit more. This is probably a mistake in handling the binary coming from erlang into the nif when calling sqlite3_open.

warmwaffles avatar Jan 30 '24 14:01 warmwaffles