elixir-sqlite / sqlitex

An Elixir wrapper around esqlite. Allows access to sqlite3 databases.
https://hex.pm/packages/sqlitex
120 stars 34 forks source link

MatchErrors #101

Closed MichaelSwartz closed 3 years ago

MichaelSwartz commented 3 years ago

If the file permissions do not allow access to the db file, instead of returning an error tuple the library throws a MatchError:

pry(1)> Sqlitex.with_db('file.db', fn db -> Sqlitex
.query(db, sql_search) end)
** (MatchError) no match of right hand side value: {:error, {:cantopen, 'unable to open database
file'}}

The same occurs if an empty sql string is passed:

pry(1)> Sqlitex.query(db, "")
** (MatchError) no match of right hand side value: {:error, :no_prepared_statement}

Thanks for providing this library! It's super useful

ConnorRigby commented 3 years ago

https://github.com/elixir-sqlite/sqlitex/blob/master/lib/sqlitex.ex#L75 this looks like it should be an easy fix.

MichaelSwartz commented 3 years ago

Thanks @ConnorRigby, that was fast!