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

Cosmos: Add support for char literals #23213

Merged
1 commit merged into from
Nov 6, 2020
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
Original file line number Diff line number Diff line change
Expand Up @@ -701,7 +701,9 @@ private static Expression TryRemoveImplicitConvert(Expression expression)
|| innerType == typeof(sbyte)
|| innerType == typeof(char)
|| innerType == typeof(short)
|| innerType == typeof(ushort))))
|| innerType == typeof(ushort)))
|| (convertedType == typeof(double)
&& (innerType == typeof(float))))
{
return TryRemoveImplicitConvert(unaryExpression.Operand);
}
Expand Down
4 changes: 3 additions & 1 deletion src/EFCore.Cosmos/Query/Internal/QuerySqlGenerator.cs
Original file line number Diff line number Diff line change
Expand Up @@ -388,7 +388,9 @@ private JToken GenerateJToken(object value, CoreTypeMapping typeMapping)
var unwrappedType = typeMapping.ClrType.UnwrapNullableType();
value = unwrappedType.IsEnum
? Enum.ToObject(unwrappedType, value)
: value;
: unwrappedType == typeof(char)
? Convert.ChangeType(value, unwrappedType)
: value;
}

var converter = typeMapping.Converter;
Expand Down
12 changes: 3 additions & 9 deletions test/EFCore.Cosmos.FunctionalTests/BuiltInDataTypesCosmosTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -17,25 +17,19 @@ public BuiltInDataTypesCosmosTest(BuiltInDataTypesCosmosFixture fixture)
{
}

[ConditionalTheory(Skip = "Issue #16919")]
[ConditionalTheory(Skip = "Issue #17246 No Explicit Convert")]
public override Task Can_filter_projection_with_inline_enum_variable(bool async)
{
return base.Can_filter_projection_with_inline_enum_variable(async);
}

[ConditionalTheory(Skip = "Issue #16919")]
[ConditionalTheory(Skip = "Issue #17246 No Explicit Convert")]
public override Task Can_filter_projection_with_captured_enum_variable(bool async)
{
return base.Can_filter_projection_with_captured_enum_variable(async);
}

[ConditionalFact(Skip = "Issue #16919")]
public override void Can_query_using_any_nullable_data_type_as_literal()
{
base.Can_query_using_any_nullable_data_type_as_literal();
}

[ConditionalFact(Skip = "Issue #16919")]
[ConditionalFact(Skip = "Issue #17246 No Explicit Convert")]
public override void Can_query_with_null_parameters_using_any_nullable_data_type()
{
base.Can_query_with_null_parameters_using_any_nullable_data_type();
Expand Down
22 changes: 5 additions & 17 deletions test/EFCore.Cosmos.FunctionalTests/CustomConvertersCosmosTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -23,25 +23,19 @@ public override void Can_perform_query_with_max_length()
// Over the 2Mb document limit
}

[ConditionalTheory(Skip = "Issue #16919")]
[ConditionalTheory(Skip = "Issue #17246 No Explicit Convert")]
public override Task Can_filter_projection_with_inline_enum_variable(bool async)
{
return base.Can_filter_projection_with_inline_enum_variable(async);
}

[ConditionalTheory(Skip = "Issue #16919")]
[ConditionalTheory(Skip = "Issue #17246 No Explicit Convert")]
public override Task Can_filter_projection_with_captured_enum_variable(bool async)
{
return base.Can_filter_projection_with_captured_enum_variable(async);
}

[ConditionalFact(Skip = "Issue #16919")]
public override void Can_query_using_any_nullable_data_type_as_literal()
{
base.Can_query_using_any_nullable_data_type_as_literal();
}

[ConditionalFact(Skip = "Issue #16919")]
[ConditionalFact(Skip = "Issue #17246 No Explicit Convert")]
public override void Can_query_with_null_parameters_using_any_nullable_data_type()
{
base.Can_query_with_null_parameters_using_any_nullable_data_type();
Expand All @@ -53,13 +47,7 @@ public override void Can_insert_and_read_back_with_string_key()
base.Can_insert_and_read_back_with_string_key();
}

[ConditionalFact(Skip = "Issue #16919")]
public override void Can_query_and_update_with_conversion_for_custom_struct()
{
base.Can_query_and_update_with_conversion_for_custom_struct();
}

[ConditionalFact(Skip = "Issue #16919")]
[ConditionalFact(Skip = "Issue #17246 No Explicit Convert")]
public override void Can_query_and_update_with_conversion_for_custom_type()
{
base.Can_query_and_update_with_conversion_for_custom_type();
Expand All @@ -83,7 +71,7 @@ public override void Can_insert_and_read_back_with_case_insensitive_string_key()
base.Can_insert_and_read_back_with_case_insensitive_string_key();
}

[ConditionalFact(Skip = "Issue #16919")]
[ConditionalFact(Skip = "Issue #17246 No Explicit Convert")]
public override void Can_insert_and_query_struct_to_string_converter_for_pk()
{
base.Can_insert_and_query_struct_to_string_converter_for_pk();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -128,20 +128,20 @@ FROM root c
WHERE ((c[""Discriminator""] = ""Customer"") AND CONTAINS(c[""ContactName""], c[""ContactName""]))");
}

[ConditionalTheory(Skip = "Issue #16919")]
public override async Task String_FirstOrDefault_MethodCall(bool async)
{
await base.String_FirstOrDefault_MethodCall(async);

AssertSql(
@"SELECT c
FROM root c
WHERE ((c[""Discriminator""] = ""Customer"") AND (LEFT(c[""ContactName""], 1) = ""A""))");
}

[ConditionalTheory(Skip = "Issue #16919")]
public override async Task String_LastOrDefault_MethodCall(bool async)
{
await base.String_LastOrDefault_MethodCall(async);

AssertSql(
@"SELECT c
FROM root c
Expand Down