IreneKnapp/direct-sqlite — pull request #13 by joeyadams (2012-08-23 04:49:54+00:00)
Title: Breaking API improvements for better error handling and type safety

This extends pull request #12. Once #12 is merged, the number of commits here should go down.

This pull request makes the following breaking changes:

* Newtypes `ParamIndex` and `ColumnIndex` are used (instead of `Int`) to improve signatures and guard against misuse.

* When SQLite3 reports an error, a SQLError is thrown instead of an IOError. This way, users can handle specific errors.

This does not change the error message displayed when a query fails, except that it no longer says "user error (...)".

* Fields in SQLData are strict now.

* `reset` and `finalize` no longer throw exceptions. See commit 85f36c7.

It also adds a few new functions: `exec`, `clearBindings`, and `bindSQLData`. `bindSQLData` binds a single value; I decided not to rename `bind` after all (see commit 697c36e).

One change that I did not make yet, which we might want to consider, is using `Text` instead of `String` for query strings and such. This might be a little less convenient to use (you have to use `{-# LANGUAGE OverloadedStrings #-}`), but it means less conversions for [sqlite-simple][1], [persistent-sqlite][2], and direct-sqlite itself.

[1]: http://hackage.haskell.org/package/sqlite-simple

[2]: http://hackage.haskell.org/package/persistent-sqlite