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

Query: Fixes regression from LINQ custom serializer fix #3749

Merged
merged 2 commits into from
Mar 10, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 0 additions & 17 deletions Microsoft.Azure.Cosmos/src/Linq/ExpressionToSQL.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ namespace Microsoft.Azure.Cosmos.Linq
using System.Collections.ObjectModel;
using System.Diagnostics;
using System.Globalization;
using System.IO;
using System.Linq;
using System.Linq.Expressions;
using System.Reflection;
Expand Down Expand Up @@ -713,22 +712,6 @@ public static SqlScalarExpression VisitConstant(ConstantExpression inputExpressi
return SqlArrayCreateScalarExpression.Create(arrayItems.ToImmutableArray());
}

if (context.linqSerializerOptions?.CustomCosmosSerializer != null)
{
StringWriter writer = new StringWriter(CultureInfo.InvariantCulture);

// Use the user serializer for the parameter values so custom conversions are correctly handled
using (Stream stream = context.linqSerializerOptions.CustomCosmosSerializer.ToStream(inputExpression.Value))
{
using (StreamReader streamReader = new StreamReader(stream))
{
string propertyValue = streamReader.ReadToEnd();
writer.Write(propertyValue);
return CosmosElement.Parse(writer.ToString()).Accept(CosmosElementToSqlScalarExpressionVisitor.Singleton);
}
}
}

return CosmosElement.Parse(JsonConvert.SerializeObject(inputExpression.Value)).Accept(CosmosElementToSqlScalarExpressionVisitor.Singleton);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -505,14 +505,11 @@ public override IOrderedQueryable<T> GetItemLinqQueryable<T>(
{
requestOptions ??= new QueryRequestOptions();

if (linqSerializerOptions == null && this.ClientContext.ClientOptions != null)
if (linqSerializerOptions == null && this.ClientContext.ClientOptions.SerializerOptions != null)
{
linqSerializerOptions = new CosmosLinqSerializerOptions
{
PropertyNamingPolicy = this.ClientContext.ClientOptions.SerializerOptions != null
? this.ClientContext.ClientOptions.SerializerOptions.PropertyNamingPolicy
: CosmosPropertyNamingPolicy.Default,
CustomCosmosSerializer = this.ClientContext.ClientOptions.Serializer
PropertyNamingPolicy = this.ClientContext.ClientOptions.SerializerOptions.PropertyNamingPolicy
};
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,15 +22,6 @@ public CosmosLinqSerializerOptions()
this.PropertyNamingPolicy = CosmosPropertyNamingPolicy.Default;
}

/// <summary>
/// Gets or sets the user defined customer serializer. If no customer serializer was defined,
/// then the value is set to the default value
/// </summary>
/// <remarks>
/// The default value is null
/// </remarks>
internal CosmosSerializer CustomCosmosSerializer { get; set; }

/// <summary>
/// Gets or sets whether the naming policy used to convert a string-based name to another format,
/// such as a camel-casing format.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -435,7 +435,7 @@ FROM root]]></SqlQuery>
</Input>
<Output>
<SqlQuery><![CDATA[
SELECT VALUE {}
SELECT VALUE {"value": null}
FROM root]]></SqlQuery>
</Output>
</Result>
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -455,7 +455,9 @@ Family createDataObj(Random random)
return getQuery;
}

public static Func<bool, IQueryable<Data>> GenerateSimpleCosmosData(Cosmos.Database cosmosDatabase)
public static Func<bool, IQueryable<Data>> GenerateSimpleCosmosData(
Cosmos.Database cosmosDatabase
)
{
const int DocumentCount = 10;
PartitionKeyDefinition partitionKeyDefinition = new PartitionKeyDefinition { Paths = new System.Collections.ObjectModel.Collection<string>(new[] { "/Pk" }), Kind = PartitionKind.Hash };
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
//-----------------------------------------------------------------------
// <copyright file="LinqTranslationBaselineTests.cs" company="Microsoft Corporation">
// <copyright file="LinqAttributeContractTests.cs" company="Microsoft Corporation">
// Copyright (c) Microsoft Corporation. All rights reserved.
// </copyright>
//-----------------------------------------------------------------------
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,6 @@
<None Remove="BaselineTest\TestBaseline\IndexMetricsParserBaselineTest.IndexUtilizationParse.xml" />
<None Remove="BaselineTest\TestBaseline\LinqTranslationBaselineTests.TestDateTimeJsonConverterTimezones.xml" />
<None Remove="BaselineTest\TestBaseline\LinqTranslationBaselineTests.TestMemberAccessWithNullableTypes.xml" />
<None Remove="BaselineTest\TestBaseline\LinqTranslationWithCustomSerializerBaseline.TestMemberInitializer.xml" />
</ItemGroup>

<ItemGroup>
Expand Down Expand Up @@ -248,9 +247,6 @@
<Content Include="BaselineTest\TestBaseline\LinqTranslationBaselineTests.TestMemberAccess.xml">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content>
<Content Include="BaselineTest\TestBaseline\LinqTranslationWithCustomSerializerBaseline.TestMemberInitializer.xml">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content>
<Content Include="Query\AggregateQueryTests.AggregateMixedTypes_baseline.xml">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content>
Expand Down