Replace SQLiteWriter d_columns with metadata call#10
Open
wandernauta wants to merge 2 commits intoberthubert:mainfrom
Open
Replace SQLiteWriter d_columns with metadata call#10wandernauta wants to merge 2 commits intoberthubert:mainfrom
wandernauta wants to merge 2 commits intoberthubert:mainfrom
Conversation
The d_columns field is removed. Instead, to find out whether some column or table exists, the sqlite3_table_column_metadata function is called. This resolves an issue where multiple connections are open to the SQLite database and calls to addValue cause columns to be added to a table that is also used by others. Before, these new columns would only be added to the d_columns list of the connection that created them, meaning that all others would be out of sync, and stay that way. If they added a row that had the new column, they would attempt an ALTER TABLE, which would fail. This change also means that we automatically follow SQLite when it comes to case sensitivity, so this should also fix berthubert#9. Finally, the code is slightly simpler. The getSchema method on MiniSQLite is now unused by the code itself, but since the method is public it is kept in case it is used by API users.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
The d_columns field is removed. Instead, to find out whether some column or table exists, the sqlite3_table_column_metadata function is called.
This resolves an issue where multiple connections are open to the SQLite database and calls to addValue cause columns to be added to a table that is also used by others. Before, these new columns would only be added to the d_columns list of the connection that created them, meaning that all others would be out of sync, and stay that way. If they added a row that had the new column, they would attempt an ALTER TABLE, which would fail.
This change also means that we automatically follow SQLite when it comes to case sensitivity, so this should also fix #9.
Finally, the code is slightly simpler.
The getSchema method on MiniSQLite is now unused by the code itself, but since the method is public it is kept in case it is used by API users.