Microsoft.Data.Sqlite: Add LoadExtension() to SqliteConnection#14789
Merged
bricelam merged 1 commit intodotnet:masterfrom Feb 28, 2019
bricelam:ext
Merged
Microsoft.Data.Sqlite: Add LoadExtension() to SqliteConnection#14789bricelam merged 1 commit intodotnet:masterfrom bricelam:ext
bricelam merged 1 commit intodotnet:masterfrom
bricelam:ext
Conversation
bricelam
commented
Feb 22, 2019
ajcvickers
reviewed
Feb 23, 2019
This also updates EFCore.Sqlite to use the new method. There is a breaking change in SpatialiteLoader. The methods used to take a DbConnection (I guess 'cause we could) but now take a SqliteConnection. You no longer need to call SqliteConnection.EnableExtensions() before using SpatialiteLoader since the new LoadExtension method will bypass the connection setting. This greatly improves usability and makes EnableExtensions only apply to the load_extension SQL function. Given this, EnableExtensions should probably have been a connection string keyword. In fact, SpatialiteLoader isn't really needed anymore since calling UseNetTopologySuite now loads the extension for open external connections. Maybe we should make it internal. LoadExtension has some unusual behavior when the connection is closed. Any exceptions will be delayed until the connection is opened, and there is no way to remove an extension you tried to load, so you'll have to create a new connection object to get back in a good state. Resolves #13826
ajcvickers
reviewed
Feb 28, 2019
| /// <param name="connection"> The connection. </param> | ||
| /// <returns> true if the extension was loaded; otherwise, false. </returns> | ||
| public static bool TryLoad([NotNull] DbConnection connection) | ||
| public static bool TryLoad([NotNull] SqliteConnection connection) |
Contributor
There was a problem hiding this comment.
Why not an extension method?
Contributor
Author
There was a problem hiding this comment.
Most people shouldn't use it. (None now that we do it for externally opened connections.)
ajcvickers
approved these changes
Feb 28, 2019
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.
This also updates EFCore.Sqlite to use the new method.
There is a breaking change in SpatialiteLoader. The methods used to take a DbConnection (I guess 'cause we could) but now take a SqliteConnection.
You no longer need to call SqliteConnection.EnableExtensions() before using SpatialiteLoader since the new LoadExtension method will bypass the connection setting. This greatly improves usability and makes EnableExtensions only apply to the load_extension SQL function. Given this, EnableExtensions should probably have been a connection string keyword.
In fact, SpatialiteLoader isn't really needed anymore since calling UseNetTopologySuite now loads the extension for open external connections. Maybe we should make it internal. (See #14821)
LoadExtension has some unusual behavior when the connection is closed. Any exceptions will be delayed until the connection is opened, and there is no way to remove an extension you tried to load, so you'll have to create a new connection object to get back in a good state.
Resolves #13826
I'll review these changes in a design meeting to make sure we're OK with them all.✔