Closed joeyadams closed 12 years ago
Looks good. Having an option for using system's SQLite binaries should make installation easier on Windows.
This is good stuff, although it should probably have been about three separate pull requests. Anyway, merged. :) Sorry for the delay, I've been busy!
@joeyadams @IreneKnapp Joey, do you consider your merged changes complete enough for a new direct-sqlite release? It'd be great to get this code out. I'd at least like to switch sqlite-simple to use the latest version.
I'd say it's ready. Granted, we might want to make some changes later on (e.g. upgrade SQLite to 3.7.14, and fix a couple minor build warnings), but I think we should release first.
Current master (7649ce4) builds, and tests pass, with GHC 7.6.1 and cabal-install version 0.13.3. However, there are a few minor deprecation warnings. Thanks to the fix for GHC ticket 7167, "Module Prelude' does not export
catch'" is a warning instead of an error.
@IreneKnapp, could you update the .cabal file to describe the new changes? I'm thinking something like:
[3.0] exports lower-level bindings, uses newtypes for parameter and column index types, throws SQL exceptions that can be caught, and uses Text instead of String even for non-data strings.
Also, could you update the homepage and bug-reports links to point to Github? The current bug-reports link gives a 403.
I'd like to slip these changes in before the next release, since there's a slight API change (
sqlErrorDetails
is nowText
instead ofMaybe Text
).A couple ideas taken from persistent-sqlite:
Handle invalid UTF-8 a little better.
Someone pointed out that:
persistent-sqlite uses decodeUtf8With lenientDecode, which replaces invalid characters with U+FFFD (the Unicode replacement character). Because that can silently corrupt data, I took an alternative approach: throw a DecodeError whose message refers to Database.SQLite3.
I also documented that a
DecodeError
may arise, and that SQLite3 does not validate UTF-8 on input.The last commit uses sqlite3_db_handle to get the
Database
of aStatement
when a call fails and only aStatement
is available. This eliminated all cases where no details were available, so I changedsqlErrorDetails
fromMaybe Text
toText
.