Stop including the discriminator in the JSON id by default#34208
Stop including the discriminator in the JSON id by default#34208ajcvickers merged 4 commits intomainfrom
Conversation
AndriySvyryd
left a comment
There was a problem hiding this comment.
How do we make sure that the Northwind database is recreated on the CI with the new values and is also correctly recreated with the old values when code from an older branch runs?
IMHO that's another good reason to not rely on a persistent database in CI, but rather to just use the emulator, where it's guaranteed to be recreated each time (I think we agreed we want to go in that direction anyway, possibly except for specific RBAC tests which can't be executed with the emulator?). If we do want to stay with non-emulator tests, we could simply recreate the database each time, but on Ci only (to avoid making local runs slow), e.g. by checking the CI environment variable. |
We need to do #19973 first
That would still not work for tests from old branches. We'd need to rename the database. |
|
@roji @AndriySvyryd New version up attempting to follow Andriy's guidance. |
bc508ac to
0c548b5
Compare
|
@roji This is now updated with fixes for discriminator checking and more tests. Can you check the test baselines to make sure you think we are doing |
roji
left a comment
There was a problem hiding this comment.
Hey, here's a review of the ReadItemPartitionKey tests only. The actual behavior seems correct to me (i.e. I haven't noticed a case where we do ReadItem when we shouldn't or vice versa). So below see mainly some comments about the structure/factoring of these tests.
As a general comment, there's maybe a bit more systematic duplication of tests across various scenarios than I'd have personally done... This is definitely a matter of personal style/taste on how to test: more black box-style "cover all permutations" vs. more white-box "think about specific scenarios you want/need to cover" (I lean much more in the latter direction). For example, do we think we need all the duplication along the only/non-only axis, as well as everything on the leaf. I'm also noting that there seem to be relatively few tests which actually differ across the different implementations (e.g. HierarchicalPartitionKeyEntity is practically identical across all versions).
But I think it's all OK, hopefully it doesn't cost us in terms of maintainability/complexity.
Regardless FYI it took me a while to understand all the test factoring here and realize what extends from what and why :) It makes sense to me now, but maybe a comment on each test class to explain what it's there for could be useful for our future selves.
| { | ||
| base.OnModelCreating(modelBuilder, context); | ||
|
|
||
| modelBuilder.IncludeDiscriminatorInJsonId(); |
There was a problem hiding this comment.
Any specific reason to do this on this specific test suite (not pushing back)?
There was a problem hiding this comment.
Because otherwise the test data results in conflicts in the JSON id values.
There was a problem hiding this comment.
Given we're gonna have so many ReadItemPartitionKey query tests, maybe they deserve their own sub-folder...
There was a problem hiding this comment.
Are you asking me to put them in a subfolder? Happy to do so, if that's what you want.
| .Where(e => e.Payload.Contains("3") && e.PartitionKey1 == "PK1" && e.PartitionKey2 == 1 && e.PartitionKey3)); | ||
| await base.Predicate_with_hierarchical_partition_key_and_additional_things_in_predicate(); | ||
|
|
||
| // Not ReadItem because no primary key value |
There was a problem hiding this comment.
Also just additional things in predicate
I very much believe that if I only do "white box" testing, then I will ship significantly more bugs. This is based on my experience of writing tests in this way and frequently finding a bug in a scenario I had never even thought of. So, at least for people of my ability, this will be a trade off for the advantages of having fewer tests against us shipping more bugs. |
f813158 to
ff8e1e7
Compare
AndriySvyryd
left a comment
There was a problem hiding this comment.
There aren't any blocking issues
Fixes #34179 There are also new APIs on the entity type and model builders to facilitate optional behaviors, including reverting to the pre-9 behavior: - Entity<Blog>().IncludeDiscriminatorInJsonId(); - Entity<Blog>().IncludeRootDiscriminatorInJsonId(); - Entity<Blog>().AlwaysCreateShadowIdProperty(); Note that this change requires regeneration of the Northwind database.
ff8e1e7 to
5af27ce
Compare
5af27ce to
7956d4b
Compare
Fixes #34179
There are also new APIs on the entity type and model builders to facilitate optional behaviors, including reverting to the pre-9 behavior:
Note that this change requires regeneration of the Northwind database.