Skip to content

Promote Json tests to Core so that they can be utilized for Cosmos.#34355

Merged
maumar merged 1 commit intomainfrom
cosmos_tests
Aug 6, 2024
Merged

Promote Json tests to Core so that they can be utilized for Cosmos.#34355
maumar merged 1 commit intomainfrom
cosmos_tests

Conversation

@maumar
Copy link
Copy Markdown
Contributor

@maumar maumar commented Aug 4, 2024

No description provided.

@maumar maumar requested review from ajcvickers and roji August 4, 2024 07:26
WHERE ((c["Discriminator"] = "Basic") AND (ARRAY(
SELECT VALUE o["OwnedReferenceLeaf"]["SomethingSomething"]
FROM o IN c["OwnedReferenceRoot"]["OwnedCollectionBranch"]
WHERE (o["Enum"] = -3))[0] = "e1_r_c2_r"))
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

@ajcvickers should we map enums to negative values like that?

"""
SELECT VALUE c
FROM root c
WHERE ((c["Discriminator"] = "AllTypes") AND (c["Reference"]["TestEnumWithIntConverter"] != -3))
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

same here, sus enum value

"""
SELECT VALUE c
FROM root c
WHERE ((c["Discriminator"] = "AllTypes") AND (c["Reference"]["TestNullableEnum"] != -1))
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

...and here

// TODO: remove all this infra once we support converters on cosmos
// also undo virtual on base
// issue #34026
public override IReadOnlyDictionary<Type, object> EntityAsserters { get; } = new Dictionary<Type, Action<object, object>>
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

this is not great, but I wanted to do as little disruption as possible - we need custom asserters because some properties with converters are not supported on cosmos and therefore are being ignored in the model. This causes entity asserters to fail (not seeing the expected data for those ignored columns). Asserters are static on the base so I just copied them here and removed the unwanted parts. Once #34026 is fixed we can remove all this code.

// TODO: issue #34067 (?)
AssertSql(
"""
SELECT VALUE c
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

@maumar maumar force-pushed the cosmos_tests branch 2 times, most recently from dba0891 to 5b5a964 Compare August 4, 2024 10:09
Copy link
Copy Markdown
Member

@roji roji left a comment

Choose a reason for hiding this comment

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

See comments below, and let's wait also for @ajcvickers comments, but otherwise LGTM - this adds some good coverage to Cosmos and uncovered some bugs. We can always improve this further later.

Re the specific issues/bugs, I can investigate after this is merged.

.IncludeDiscriminatorInJsonId()
.HasDiscriminator<string>("Discriminator").HasValue("Basic");

modelBuilder.Entity<JsonEntityBasic>().Property(x => x.Id).ValueGeneratedNever();
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

We should maybe move away from value-generated IDS by default... As they're not supported across all databases, and have little value where we're defining the test data - better to just hardcode the ID values like we hardcode the rest of the properties in the test data?

{
bb.OwnsOne(x => x.OwnedReferenceLeaf);
bb.OwnsMany(x => x.OwnedCollectionLeaf);
bb.Property(x => x.Fraction).HasPrecision(18, 2);
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Does this mean something in Cosmos? /cc @ajcvickers

Comment thread test/EFCore.Cosmos.FunctionalTests/Query/JsonQueryCosmosTest.cs Outdated
Comment thread test/EFCore.Cosmos.FunctionalTests/Query/JsonQueryCosmosTest.cs
Comment thread test/EFCore.Cosmos.FunctionalTests/Query/JsonQueryCosmosTest.cs Outdated
Comment thread test/EFCore.Cosmos.FunctionalTests/Query/JsonQueryCosmosTest.cs
Comment thread test/EFCore.Relational.Specification.Tests/Query/JsonQueryFixtureBase.cs Outdated
Comment thread test/EFCore.Relational.Specification.Tests/Query/JsonQueryRelationalFixture.cs Outdated
Comment thread test/EFCore.Relational.Specification.Tests/Query/JsonQueryRelationalTestBase.cs Outdated
Comment thread test/EFCore.Cosmos.FunctionalTests/Query/JsonQueryCosmosTest.cs Outdated
@maumar maumar force-pushed the cosmos_tests branch 2 times, most recently from d3f598a to a0b085d Compare August 6, 2024 01:32
@maumar maumar merged commit 424c08b into main Aug 6, 2024
@maumar maumar deleted the cosmos_tests branch August 6, 2024 19:15
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.

2 participants