Skip to content
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

Closed
AdamSLevy opened this issue Jul 24, 2019 · 1 comment
Closed

No way to know if Value methods will panic #61

AdamSLevy opened this issue Jul 24, 2019 · 1 comment

Comments

@AdamSLevy
Copy link
Collaborator

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.

AdamSLevy added a commit to AdamSLevy/sqlite that referenced this issue Jul 29, 2019
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
AdamSLevy added a commit to AdamSLevy/sqlite that referenced this issue Jul 29, 2019
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
@AdamSLevy
Copy link
Collaborator Author

AdamSLevy commented Jul 30, 2019

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
Let me know if this is some functionality that you would like to merge into sqlitex, because I feel it is out of place in a package of its own.

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant