-
Notifications
You must be signed in to change notification settings - Fork 292
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
persistent-sqlite should depend on direct-sqlite #92
Comments
For whatever it's worth, as the author of direct-sqlite I consider it to be still maintained and would love to hear what you feel needs changing in it. |
It's been a while, so I don't remember my reasons at the time, but I think it was because I wanted to allow embedding of the sqlite3.c file instead of depending on the system-installed one, as that simplifies Windows installation. Another major change is that persistent-sqlite uses the PersistValue datatype directly instead of having to perform an extra conversion step. I see that in more recent versions the source file was added, so that's at least one issue ticked off the list. So @joeyadams: If you want to take a stab at making the move, I give no objections. One thing to point out in advance is that I had to implement a hack in the amalgamation itself to get GHCi to work on Linux, see d7daf0b |
I agree that the intermediate value is a problem and have been thinking about what to do about it. Anyway, cool, glad to hear this can move ahead. :) |
What if we create an even lower-level binding (we could call it "direct-sqlite-bindings") ? One that does not perform datum conversion or throw exceptions, but does translate constants like error codes and column types. This way, conversion and error handling strategy can be decided at a higher level. By the way, I spotted this in persistent-sqlite:
Why is the error handling commented out here? I have a guess. If the most recent call to
Here, finalize will throw the exception again, rather than silently free the statement. |
I think the reason I implemented that was that calling reset or finalize changes the error message we end up getting, giving us a cryptic constraint message or some such instead of the actual error caused by the step. |
direct-sqlite has been updated, but I'm still waiting for @IreneKnapp to decide if we're ready to release it yet. I noticed that, when converting to Text, persistent-sqlite uses decodeUtf8With lenientDecode instead of just decodeUtf8. This means that if invalid UTF-8 is detected, it will silently clobber the data with Unicode replacement characters ( |
PS: |
We could write our own variant of
This way, users can catch UnicodeException to handle invalid UTF-8 in the database. We'll probably want to use |
Yup, that'd be fine. It would give the same result as using |
Here's how decodeUtf8' is implemented:
What I'm proposing is that, instead of catching a UnicodeException, modifying it to have a better description, and throwing a new UnicodeException, we just use a description containing "Database.SQLite3" in it to begin with. So I guess it would be the same result as using |
Eeks, I've never looked at |
@joeyadams are you still interested in moving this to use direct-sqlite ? |
Closing out old issues, please reopen if still relevant |
The persistent-sqlite package currently contains
But copied code leads to copied issues, such as:
Error
enumerationCan we make
persistent-sqlite
import its low-level functionality fromdirect-sqlite
, rather than copying it? I'd be happy to do the integration work.The text was updated successfully, but these errors were encountered: