-
Notifications
You must be signed in to change notification settings - Fork 67
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
No way to know if Value methods will panic #61
Comments
Previously it was impossible to access the sqlite3_value_type() function for a Value. Now this is exposed via Value.Type(). Additionally, it was impossible to know if a returned Value was actually nil, which can occur when ChangesetIter.New() has no change for the given column. Using any of the returned Value's methods would result in panic. Now this can be checked using Value.IsNil(). Also, Value.Blob() is now implemented. Issue crawshaw#61
Previously it was impossible to access the sqlite3_value_type() function for a Value. Now this is exposed via Value.Type(). Additionally, it was impossible to know if a returned Value was actually nil, which can occur when ChangesetIter.New() has no change for the given column. Using any of the returned Value's methods would result in panic. Now this can be checked using Value.IsNil(). Also, Value.Blob() is now implemented. Issue crawshaw#61
Using the added functionality of PR #64 I implemented a Changeset to SQL converter so that manually examining changeset blobs can be easier. All that is required is an open connection to a database with the equivalent schema of the one the changeset was generated against, so that column names can be querried. My first draft can be found here: https://github.com/AdamSLevy/sqlitechangeset BTW on a more personal note I saw your talk on SQLite and Go in Seattle at the Go Northwest conference. That is what originally turned me onto this library. |
As it stands, there is no way to know if the Value object's method's will panic. Using ChangesetIter then becomes very difficult for analyzing a changeset. With the current design, it is impossible to know which column's have actually changed without getting the Old or New values by column index and then recovering from a panic if the Value happens to hold a nil pointer.
Ultimately, I want a clean way to print a changeset in a human readable way. But this is difficult and clumsy with the current API, even when I know the schema exactly.
The text was updated successfully, but these errors were encountered: