Skip to content
Open
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

This file was deleted.

4,108 changes: 0 additions & 4,108 deletions test/EFCore.Cosmos.FunctionalTests/Query/AdHocJsonQueryCosmosTest.cs

This file was deleted.

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -487,6 +487,300 @@ public override Task Same_entity_with_complex_type_projected_twice_with_pushdown
public override Task Same_complex_type_projected_twice_with_pushdown_as_part_of_another_projection(bool async)
=> AssertTranslationFailed(() => base.Same_complex_type_projected_twice_with_pushdown_as_part_of_another_projection(async));

// https://github.com/Azure/azure-cosmos-db-emulator-docker/issues/288 (Complex-type equality comparisons return no results)
public override async Task Complex_type_equals_parameter_with_nested_types_with_property_of_same_name()
{
CosmosTestEnvironment.SkipOnLinuxEmulator();

await base.Complex_type_equals_parameter_with_nested_types_with_property_of_same_name();
}

public override async Task Projecting_complex_property_does_not_auto_include_owned_types()
{
await base.Projecting_complex_property_does_not_auto_include_owned_types();

AssertSql(
"""
SELECT VALUE c["Complex"]
FROM root c
""");
}

public override async Task Optional_complex_type_with_discriminator()
{
await base.Optional_complex_type_with_discriminator();

AssertSql(
"""
SELECT VALUE c
FROM root c
WHERE (c["AllOptionalsComplexType"] = null)
OFFSET 0 LIMIT 2
""",
//
"""
SELECT VALUE c
FROM root c
""");
}

public override async Task Non_optional_complex_type_with_all_nullable_properties()
{
await base.Non_optional_complex_type_with_all_nullable_properties();

AssertSql(
"""
SELECT VALUE c
FROM root c
OFFSET 0 LIMIT 2
""");
}

public override async Task Non_optional_complex_type_with_all_nullable_properties_via_left_join()
{
Assert.Equal(
CosmosStrings.UpdateConflict("1"),
(await Assert.ThrowsAsync<DbUpdateException>(
base.Non_optional_complex_type_with_all_nullable_properties_via_left_join)).Message);

AssertSql();
}

public override async Task Nullable_complex_type_with_discriminator_and_shadow_property()
{
await base.Nullable_complex_type_with_discriminator_and_shadow_property();

AssertSql(
"""
SELECT VALUE c
FROM root c
""");
}

public override async Task Nullable_complex_type_with_discriminator_null_to_non_null_roundtrip()
{
await base.Nullable_complex_type_with_discriminator_null_to_non_null_roundtrip();

AssertSql(
"""
SELECT VALUE c
FROM root c
OFFSET 0 LIMIT 2
""",
//
"""
SELECT VALUE c
FROM root c
OFFSET 0 LIMIT 2
""");
}

public override async Task Nullable_complex_type_with_discriminator_non_null_to_null_roundtrip()
{
await base.Nullable_complex_type_with_discriminator_non_null_to_null_roundtrip();

AssertSql(
"""
SELECT VALUE c
FROM root c
OFFSET 0 LIMIT 2
""",
//
"""
SELECT VALUE c
FROM root c
OFFSET 0 LIMIT 2
""");
}

public override async Task Nullable_complex_type_with_discriminator_update_non_null_entity_roundtrip()
{
await base.Nullable_complex_type_with_discriminator_update_non_null_entity_roundtrip();

AssertSql(
"""
SELECT VALUE c
FROM root c
OFFSET 0 LIMIT 2
""",
//
"""
SELECT VALUE c
FROM root c
OFFSET 0 LIMIT 2
""");
}

public override Task Nullable_complex_type_with_discriminator_set_to_different_value()
=> base.Nullable_complex_type_with_discriminator_set_to_different_value();

public override async Task Nullable_complex_type_with_discriminator_set_to_null()
{
// On Cosmos, setting the discriminator shadow property to null doesn't affect materialization
// because the complex property's data is still present in the JSON document.
var contextFactory = await InitializeNonSharedTest<Context38119>();

Guid entityId;
await using (var context = contextFactory.CreateDbContext())
{
var entity = new Context38119.EntityType
{
Id = Guid.NewGuid(),
Prop = new Context38119.OptionalComplexProperty { OptionalValue = true }
};
context.Add(entity);
entityId = entity.Id;

var discriminatorEntry = context.Entry(entity).ComplexProperty(e => e.Prop).Property("Discriminator");
Assert.Equal("OptionalComplexProperty", discriminatorEntry.CurrentValue);
discriminatorEntry.CurrentValue = null;
await context.SaveChangesAsync();
}

await using (var context = contextFactory.CreateDbContext())
{
var entity = await context.Set<Context38119.EntityType>().SingleAsync(e => e.Id == entityId);
Assert.NotNull(entity.Prop);
Assert.True(entity.Prop.OptionalValue);
}
}

public override async Task Nested_nullable_complex_type_with_discriminator_null_to_non_null_roundtrip()
{
await base.Nested_nullable_complex_type_with_discriminator_null_to_non_null_roundtrip();

AssertSql(
"""
SELECT VALUE c
FROM root c
OFFSET 0 LIMIT 2
""",
//
"""
SELECT VALUE c
FROM root c
OFFSET 0 LIMIT 2
""");
}

public override async Task Update_entity_with_nullable_complex_type_and_discriminator_does_not_throw()
{
await base.Update_entity_with_nullable_complex_type_and_discriminator_does_not_throw();

AssertSql(
"""
SELECT VALUE c
FROM root c
OFFSET 0 LIMIT 2
""",
//
"""
SELECT VALUE c
FROM root c
OFFSET 0 LIMIT 2
""");
}

public override async Task Can_query_by_complex_type_property_with_index()
{
await base.Can_query_by_complex_type_property_with_index();

AssertSql(
"""
SELECT VALUE c
FROM root c
WHERE (c["Address"]["City"] = "Seattle")
OFFSET 0 LIMIT 2
""");
}

public override async Task Can_update_entity_with_index_on_complex_type_property()
{
await base.Can_update_entity_with_index_on_complex_type_property();

AssertSql(
"""
SELECT VALUE c
FROM root c
OFFSET 0 LIMIT 2
""",
//
"""
SELECT VALUE c
FROM root c
OFFSET 0 LIMIT 2
""");
}

public override async Task Can_delete_entity_with_index_on_complex_type_property()
{
await base.Can_delete_entity_with_index_on_complex_type_property();

AssertSql(
"""
SELECT VALUE c
FROM root c
OFFSET 0 LIMIT 2
""",
//
"""
SELECT VALUE COUNT(1)
FROM root c
""");
}

public override async Task Can_query_by_alternate_key_on_complex_type_property()
{
await base.Can_query_by_alternate_key_on_complex_type_property();

AssertSql(
"""
SELECT VALUE c
FROM root c
WHERE (c["Address"]["City"] = "Redmond")
OFFSET 0 LIMIT 2
""");
}

public override async Task Can_save_batch_swapping_alternate_key_values_on_complex_type_property()
{
// Unlike relational providers, Cosmos can't ORDER BY the primary-key path 'Id.Id': the model defines an
// explicit index (on Address.PostalCode), which disables automatic indexing and therefore excludes the
// 'Id.Id' path from the index. Order client-side instead - the test's intent (reading the alternate-key
// values while building batch edges) is unaffected.
var contextFactory = await InitializeNonSharedTest<Context31246>(
seed: context =>
{
context.AddRange(
new Context31246.Person
{
Id = new Context31246.StronglyTypedId(1),
Address = new Context31246.Address { City = "Seattle", PostalCode = "98101" }
},
new Context31246.Person
{
Id = new Context31246.StronglyTypedId(2),
Address = new Context31246.Address { City = "Redmond", PostalCode = "98052" }
});
return context.SaveChangesAsync();
});

await using (var context = contextFactory.CreateDbContext())
{
var people = (await context.Set<Context31246.Person>().ToListAsync()).OrderBy(p => p.Id.Id).ToList();
people[0].Address.PostalCode = "98103";
people[1].Address.PostalCode = "98054";
await context.SaveChangesAsync();
}

await using (var context = contextFactory.CreateDbContext())
{
var people = (await context.Set<Context31246.Person>().ToListAsync()).OrderBy(p => p.Id.Id).ToList();
Assert.Equal("98103", people[0].Address.PostalCode);
Assert.Equal("98054", people[1].Address.PostalCode);
}
}

#region GroupBy

[Theory(Skip = "#17313 Cosmos: Translate GroupBy")]
Expand Down
Loading
Loading