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

Sqlite: Empty string init and coalescing for various properties #20172

Merged
merged 1 commit into from
Apr 17, 2020

Conversation

roji
Copy link
Member

@roji roji commented Mar 4, 2020

Closes #20171

@roji roji requested a review from bricelam March 4, 2020 13:58
@roji roji changed the title Empty string init and coalescing for various properties Sqlite: Empty string init and coalescing for various properties Mar 5, 2020
private ConnectionState _state;
private sqlite3 _db;
private bool _extensionsEnabled;

private static readonly SqliteConnectionStringBuilder _emptyConnectionOptions = new SqliteConnectionStringBuilder();
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This seems dangerous since SqliteConnectionStringBuilder is mutable. I assume we never mutate it?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yep, I did a check and your codebase seems to be only reading from it (which seems like a good thing - mutable by the user, not by the driver). Are you good with this?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

SqlClient splits it into a mutable and an immutable type (for perf mostly). But I was lazy.

I'm good with it


Assert.Equal(Resources.OpenRequiresSetConnectionString, ex.Message);
using var connection = new SqliteConnection();
connection.Open();
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Dude, where's my data? :trollface:

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added a SELECT 1 after this, that's what you meant right? Just to note that there are various other Open tests which don't do this.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No, I just mean that most people will have no idea what this does and will be confused when their database is deleted when the connection is closed.

The test is fine

@roji roji requested a review from bricelam March 15, 2020 00:05
@roji roji merged commit 2f2fc38 into dotnet:master Apr 17, 2020
@roji roji deleted the SqliteEmptyStrings branch February 22, 2021 10:01
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

Successfully merging this pull request may close these issues.

Sqlite: initialize and coalesce various string properties to empty string
2 participants