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
SpannerConnectionStringBuilder.ConversionOptions are set inconsistently #9158
Comments
Looking at this again, we have a slight issue when setting ConnectionString, if the previous connection string specified conversion options but the new one doesn't. Here's a failing test: [Fact]
public void SettingConnectionStringResetsConversionOptions()
{
var builder = new SpannerConnectionStringBuilder();
builder.ConnectionString = "SpannerToClrTypeDefaultMappings=DateToSpannerDate";
builder.ConnectionString = "";
Assert.Equal(SpannerConversionOptions.Default.DateToConfiguredClrType, builder.ConversionOptions.DateToConfiguredClrType);
} Basically I suspect we want to create conversion options lazily, rather than responding to keys being set explicitly. Will fix this. |
Ah - it's actually fairly straightforward; we just need to override |
Hi @jskeet - This seems to have been introduced by me. I can take a look at it and make the changes after discussing it with you tomorrow. Please let me know. |
I've fixed it in a PR that I'll be sending later :) |
…conversion options Fixes googleapis#9158
…conversion options Fixes googleapis#9158
Changes in Google.Cloud.Spanner.Data version 4.2.0: ### Bug fixes - Fix SpannerConnectionStringBuilder.ConnectionString handling of conversion options. Fixes [issue 9158](googleapis#9158) ([commit 92ba08b](googleapis@92ba08b)) ### New features - Update transaction.proto to include different lock modes ([issue 9236](googleapis#9236)) ([commit 4fed510](googleapis@4fed510)) - Add support for FGAC in Spanner ([commit 4e7eddb](googleapis@4e7eddb)) - Update result_set.proto to return undeclared parameters in ExecuteSql API ([commit cb86746](googleapis@cb86746)) - Support dependency injection of SpannerConnection ([commit f29a7f9](googleapis@f29a7f9)) - Support custom GoogleCredential in SpannerConnectionStringBuilder/SpannerConnection ([commit 898d3b3](googleapis@898d3b3)) - Added support for JSONB type in the PostgreSQL dialect. Note that JSONB arrays are not supported server-side yet. Packages in this release: - Release Google.Cloud.Spanner.Admin.Database.V1 version 4.2.0 - Release Google.Cloud.Spanner.Admin.Instance.V1 version 4.2.0 - Release Google.Cloud.Spanner.Common.V1 version 4.2.0 - Release Google.Cloud.Spanner.Data version 4.2.0 - Release Google.Cloud.Spanner.V1 version 4.2.0
When
SpannerConnection.ConnectionString
is set, it calls theSpannerConnectionStringBuilder(string, ChannelCredential, SessionPoolManager)
constructor... whereas theClone()
method explicitly copiesConversionOptions
from the source.It's unclear whether setting SpannerConnectionStringBuilder.ConnectionString uses the indexer to set each value (in which case we don't need to copy it in Clone) or whether it's lost in the
SpannerConnectionStringBuilder(string, ChannelCredential, SessionPoolManager)
constructor.We should be consistent and document the reasoning.
The text was updated successfully, but these errors were encountered: