-
Notifications
You must be signed in to change notification settings - Fork 3.4k
Cosmos: Modernize materializer & subdocument projectionbinding #38550
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
Open
JoasE
wants to merge
283
commits into
dotnet:main
Choose a base branch
from
JoasE:feature/#34567-Materialization
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from 250 commits
Commits
Show all changes
283 commits
Select commit
Hold shift + click to select a range
984208d
Fix do not translate non-persisted properties
JoasE 62730cc
Add tests
JoasE d33a451
Copy over fix for ToList projections
JoasE f48d075
Implement ReadItem and Paging enumarators
JoasE 4d937b8
Allow inheritance hiarchies in JsonEntityMaterializerRewriter? TODO: …
JoasE 7bc7bd5
Non value projections TODO: Improve
JoasE b7d16f8
Numbers and mathematics
JoasE d524374
Fix inheritance
JoasE 4e4fa83
WIP
JoasE f91a45c
WIP
JoasE 654ae55
WIP
JoasE c9e0b86
WIP
JoasE 611d8a6
WIP
JoasE 0c6a507
WIP
JoasE fecd0d0
WIP
JoasE fd1adb8
WIP
JoasE 5ab9c5e
Revert changes
JoasE 99dc183
WIP: Working non collections
JoasE fe499e6
Fix nested collection
JoasE 1fd10b8
WIP: CollectionShaper?
JoasE 5747ad1
Fix owned mappings
JoasE 9c4de60
Select method
JoasE 865a911
Select_nested_collection_on_optional_associate
JoasE 4bc3bcc
ShapedQueryCompilingExpressionVisitor fix?
JoasE 04a1dba
Fix tracking variable
JoasE b3960d7
Fix ownerMappings
JoasE d2adfb0
Fix entityEntry
JoasE a0802db
Merge branch 'feature/#34067-ProjectSubDocuments' into feature/#34567…
JoasE aa3b472
Fix merge conflicts
JoasE fe18c49
WIP subquery
JoasE 46bed52
nested collection
JoasE 7c91ced
AssertTranslationFailed
JoasE c60455a
Distinct associate
JoasE eed0efe
Owned tests cleanup
JoasE fcab84e
Complex and value types
JoasE 0426383
Bind complex collections via CollectionShaperExpression
JoasE 29b7ae0
Throw for structural subquery projections
JoasE 86e09b5
Select_nullable_value_type_with_Value
JoasE 0959bed
Fix contains
JoasE dcd9017
Update tests
JoasE a7cfdf6
Do not translate untranslatable projections in aggregate functions an…
JoasE 7adc5f2
Allow binding QueryParameterExpression
JoasE e4842a8
Add CreateFromType to CosmosNumberProjectionTypeMapping
JoasE 0aea342
Readd client projection
JoasE 3393e0e
Select nullable client projection
JoasE 11398e0
Project constants and query parameters server side when not using cli…
JoasE 637e1e2
Remove old code
JoasE d25640f
readd: Translate ToList to ARRAY() in projection binding
JoasE 3a32c1e
Add todo
JoasE 7387e2f
Merge branch 'main' of https://github.com/dotnet/efcore into feature/…
JoasE b37bc6b
fix test
JoasE dc4ee4d
WIP: 21006
JoasE 0cae8e2
Fix max min ref types
JoasE bde0b41
Update tests
JoasE b699e49
Throw correct exception for discriminator
JoasE 3cd364b
Update test
JoasE 3b779be
Update tests
JoasE d462710
Verify no client constants
JoasE 899e5dd
Only deny linq methods over queries
JoasE ecc5455
Small clean
JoasE 07ad1da
Update test assertions
JoasE 2abcd7d
Fix distinct over subquery not allowed and allow distinct over owned
JoasE ac1ad76
Update tests
JoasE dd11a05
Skip convert number tests
JoasE 5273c40
add todo
JoasE f1cf92f
add CosmosJsonNumberProjectionReaderWriter issue
JoasE f87f85d
Fix inheritance converted fixup
JoasE 10312d5
WIP: Where_collection_navigation_ToArray_Length_member
JoasE 8c671e9
More translating subquery
JoasE 1f13565
Remove unused test
JoasE 8bb1261
Fix jobject property removed test assertions
JoasE f4231a2
style fix
JoasE e3638c6
Support reading response from internal sdk memory stream wrapper
JoasE 85c162c
Add todo
JoasE 7044c02
Add FromJsonTyped for cosmos StringKeyedDictionary
JoasE 655fe67
Add message
JoasE e7d217e
Fix non persisted properties Can_change_nested_instance_non_derived
JoasE 9e25f6a
Add totdo
JoasE 4f06112
Remove old file
JoasE e4d2365
Throw better exception and add todo
JoasE de4195d
Remove jobject references
JoasE 2c2be05
Regen compiled models removes __jobject
JoasE 0d86cf0
Update tests for error message
JoasE d76aa61
Move some stuff and update test
JoasE f0f56c4
small clean CosmosProjectionBindingExpressionVisitor
JoasE 1c2372c
small clean
JoasE 075bf0c
add comment
JoasE 4978c8f
Clean
JoasE 3871a58
Fix test
JoasE ab531f1
Ali
JoasE da6927e
Small clean
JoasE 499dee5
WIP
JoasE a1662ec
WIP
JoasE 3bcf0e2
WIP
JoasE d0d9930
WIP
JoasE 736d145
Use constant for property name bytes
JoasE cef546a
WIP
JoasE 9f7a270
WIP
JoasE 27fc549
WIP
JoasE bd2b03b
WIP: Move to new method: Discriminator done
JoasE b05d49f
Rename
JoasE 25c2733
WIP: new method: layout
JoasE 1315eb9
WIP: nested structural properties in same class
JoasE 0bdb419
WIP
JoasE 6787550
WIP: Shaper, Materializer
JoasE 9563631
WIP
JoasE ef9650d
WIP
JoasE dd6de78
Use ReadJsonPropertyValue
JoasE 64a50b9
Remove redundant parameter
JoasE 33b5061
Small read order fixes
JoasE e0a5df1
Fixes
JoasE 3c4cdc7
More order fixes and fix princi
JoasE a953ec8
Collection struct
JoasE b550f56
Fix shadowsnapshot index?
JoasE 04f0087
Empty collection fixes
JoasE 4da215f
Null check
JoasE 1f9776f
Tracking typo and shadowsnapshot order
JoasE fdc1b69
Non tracking order fixes
JoasE 75f7854
Fix principal prop
JoasE a6dd41d
Clean?
JoasE c886d3b
Reference fixup order
JoasE 66dd84c
Fix select duplicate and preparing changes for deferred bindings
JoasE 3a4ba6d
Readd shape ProjectionBindingExpression & fixes for deferred projecti…
JoasE be3ae5d
CollectionShaperExpression
JoasE a2ec9af
Small complex type fixes
JoasE 9df706e
(Nullable) value types
JoasE 86e40b4
R
JoasE d4b3e7e
Fix empty shaper
JoasE 71f50c5
Use shaper in read item
JoasE 124fbfd
add todo
JoasE 36bdbe9
fix always find
JoasE ba15fe4
clean
JoasE 5855b5d
Add docs
JoasE d7a2907
Allow late discriminators for now
JoasE 46db085
Ordinal keys
JoasE 506be16
fix typo
JoasE b38594d
Rewrite PopulateList
JoasE 14a9d7f
Null collection
JoasE 9849857
undefined
JoasE f4ca50d
Ordinal key top level fixes
JoasE 6f19047
Throw for collection token when expecting object
JoasE fc4af02
c
JoasE 6f2aeba
Add docs and clean collection materializer
JoasE 28b4538
Clean
JoasE 2f41a4f
Structural property on derived type
JoasE 8a348f9
Don't set principals for non owned navigations
JoasE 9371edb
Clean
JoasE 706971d
Fix
JoasE bbac0a7
Clean
JoasE a977e16
Keyless entities + clean
JoasE ae40e3e
Add property names
JoasE 292bc54
Fix multiple same projection bindings
JoasE 932bb9a
Fix: do not empty stored
JoasE 6dd0723
Add IsPersisted extension method for property
JoasE 4f0bd0d
Fix: Do not remove persisted principal properties
JoasE 858accd
Add todos and fix inner shaper
JoasE 47905d4
Clean
JoasE 07d6541
Move code to more appropriate place
JoasE 2bee00a
Fix non persisted properties
JoasE 59b2df5
Clean & fix setting reference and ordinal key fixups
JoasE f4d8a51
Rena
JoasE 572b739
Fix
JoasE 3abb7f5
Bring back materialization context for MaterializationInterceptionData
JoasE 8841d3a
ConvertIfNotMatch
JoasE f7fd30e
Fix
JoasE c99e418
Decimal fix appendix
JoasE 9dd901e
Null converters
JoasE 8a56358
Improve ProjectionBinding (fix select distinct associate
JoasE de4de8d
Clean up 34067
JoasE c5ffb49
Add some tests
JoasE f04881a
Disallow subqueries over structural types (never worked)
JoasE 27d7fda
Fix projection binding over structural subquery
JoasE 83c3ccb
Change docs
JoasE 49d1911
WIP: Try use ordinal for AsNoTrackingWithIdentityResolution (doesn't …
JoasE bf527fe
Clean
JoasE 42a9a3e
Validate Cosmos owned projections for identity resolution
JoasE e22ba51
Move Cosmos key projections before owned entity projections
JoasE 477d0a9
Fix Cosmos owned projection key materialization
JoasE da77e14
WIP
JoasE 1d4c117
WI
JoasE 0933d3b
WIP
JoasE 730408f
Add ordinal tests
JoasE 80089e7
WIP
JoasE cff03de
WIP: Fixup dependent to princi
JoasE 9f19f4d
Small clean and fixes tracking owned collection duplicates?
JoasE b5dbdf4
Add discriminator optimization and pk null checks
JoasE 98d4172
Fix Old_still_works
JoasE 35877d4
Merge branch 'main' of https://github.com/dotnet/efcore into feature/…
JoasE 1c404ff
Fix: Use new cosmos type mapping
JoasE 519130e
Allow complex type indexes
JoasE d306b45
Update test baselines
JoasE b38b812
Clean
JoasE 84ac2dc
Clean
JoasE b2b2883
Do not check discriminator for complex types #38119
JoasE a7518e1
Remove Conditional
JoasE ef726a0
Rewrite api baselines
JoasE d42bad0
Clean
JoasE 8dbb6eb
Clean
JoasE b095674
Clean
JoasE 14fa377
Add Cosmos sync query execution tests
JoasE 2325dd1
Fix JSON reader data test assertions
JoasE de3e368
Trim newlines when reading json
JoasE 7d6bd9e
Merge branch 'main' of https://github.com/dotnet/efcore into feature/…
JoasE fc4cc32
Add separate assertions for real cosmos db in AdHocFullTextSearchCosm…
JoasE 04986d1
Remove question: awsner no
JoasE f321434
Dirty: Put discriminator first
JoasE a7aa6a7
Add message for null item in collection (same as relational)
JoasE 8c75952
Move concurrency detection back to original place & update test
JoasE 36150e9
Remove question and add to
JoasE 3c268ba
Remove todo add to pr
JoasE bfd115a
Remove todo add to PR
JoasE d532e67
Remove TODO
JoasE 7c618ab
Remove todo, seems unsafe
JoasE 8248b50
Improve Cosmos response stream buffer extraction
JoasE 44ed03e
Remove todo: Validated
JoasE 3280945
Refactor Cosmos shaper processing
JoasE 3713c6c
Fix Cosmos materialization edge cases
JoasE 6968a7f
Throw for undefined projections (as per https://github.com/dotnet/efc…
JoasE 5ad4cf9
Dispose response message
JoasE f344005
Skip emulator tests that fail because of emulator projection order
JoasE 9522d07
Skip new tests
JoasE e575304
Extract Cosmos documents response helper
JoasE 6860e84
Clean
JoasE 7fd0677
clean
JoasE e724f1b
Fix ordinal
JoasE 7855d88
Update NorthwindFunctionsQueryCosmosTest.cs
JoasE d9005c8
fix typo
JoasE f264092
fix typo
JoasE dedb014
cLEAN
JoasE 0a42009
clean
JoasE 0f8eee5
Add some docs
JoasE eea7f70
Fix medim comments
JoasE b8a518a
Clean CosmosProjectionBindingExpressionVisitor
JoasE 0ff2f65
Remove old todos
JoasE bbf1929
Clean
JoasE 742a3b6
Add byte type to number projection and add separate method for non id…
JoasE 8d8d3a5
Bring back previous (non-skipping) NoSyncTest behaviour and use if fo…
JoasE 8bf6954
Created issue for t
JoasE d647f71
Add check for include
JoasE df1839e
Fix numberprojection tests
JoasE 35f57ee
Small fixes
JoasE fc185cf
Skip tests on emula
JoasE eb0c734
Apply suggestions from code review
JoasE 0cc5bd7
Add test and change comment
JoasE 622cdc0
Fix nullables for projection numbers
JoasE dfaaf34
Clean
JoasE 783a1cf
Clean null discriminator case
JoasE a086163
Use default for for reading null properties (matches 10.0) and add tests
JoasE 2e690ff
Remove todo: done
JoasE f8e836f
Apply suggestion
JoasE File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
23 changes: 23 additions & 0 deletions
23
src/EFCore.Cosmos/Extensions/Internal/CosmosPropertyExtensions.cs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,23 @@ | ||
| // Licensed to the .NET Foundation under one or more agreements. | ||
| // The .NET Foundation licenses this file to you under the MIT license. | ||
|
|
||
| namespace Microsoft.EntityFrameworkCore.Cosmos.Extensions.Internal; | ||
|
|
||
| /// <summary> | ||
| /// This is an internal API that supports the Entity Framework Core infrastructure and not subject to | ||
| /// the same compatibility standards as public APIs. It may be changed or removed without notice in | ||
| /// any release. You should only use it directly in your code with extreme caution and knowing that | ||
| /// doing so can result in application failures when updating to a new Entity Framework Core release. | ||
| /// </summary> | ||
| public static class CosmosPropertyExtensions | ||
| { | ||
| /// <summary> | ||
| /// This is an internal API that supports the Entity Framework Core infrastructure and not subject to | ||
| /// the same compatibility standards as public APIs. It may be changed or removed without notice in | ||
| /// any release. You should only use it directly in your code with extreme caution and knowing that | ||
| /// doing so can result in application failures when updating to a new Entity Framework Core release. | ||
| /// </summary> | ||
| public static bool IsPersisted(this IReadOnlyProperty property) | ||
| => property.GetJsonPropertyName() != string.Empty; | ||
|
|
||
| } | ||
43 changes: 43 additions & 0 deletions
43
src/EFCore.Cosmos/Extensions/Internal/CosmosResponseStreamHelper.cs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,43 @@ | ||
| // Licensed to the .NET Foundation under one or more agreements. | ||
| // The .NET Foundation licenses this file to you under the MIT license. | ||
|
|
||
| namespace Microsoft.EntityFrameworkCore.Cosmos.Extensions.Internal; | ||
|
|
||
| /// <summary> | ||
| /// This is an internal API that supports the Entity Framework Core infrastructure and not subject to | ||
| /// the same compatibility standards as public APIs. It may be changed or removed without notice in | ||
| /// any release. You should only use it directly in your code with extreme caution and knowing that | ||
| /// doing so can result in application failures when updating to a new Entity Framework Core release. | ||
| /// </summary> | ||
| public static class CosmosResponseStreamHelper | ||
| { | ||
| /// <summary> | ||
| /// This is an internal API that supports the Entity Framework Core infrastructure and not subject to | ||
| /// the same compatibility standards as public APIs. It may be changed or removed without notice in | ||
| /// any release. You should only use it directly in your code with extreme caution and knowing that | ||
| /// doing so can result in application failures when updating to a new Entity Framework Core release. | ||
| /// </summary> | ||
| public static ReadOnlyMemory<byte> ExtractContentAsMemory(Stream content) | ||
| { | ||
| if (content is MemoryStream memoryStream | ||
| && memoryStream.TryGetBuffer(out var segment)) | ||
| { | ||
| return segment.AsMemory( | ||
| checked((int)memoryStream.Position), | ||
| checked((int)(memoryStream.Length - memoryStream.Position))); | ||
| } | ||
|
|
||
| // SDK returns a memory stream in most cases, but sometimes it returns its own internal wrapper of a MemoryStream. | ||
| // In that case, copy to a single, exactly-sized buffer. | ||
| var length = checked((int)(content.Length - content.Position)); | ||
| if (length == 0) | ||
| { | ||
| return ReadOnlyMemory<byte>.Empty; | ||
| } | ||
|
|
||
| var buffer = GC.AllocateUninitializedArray<byte>(length); | ||
| content.ReadExactly(buffer); | ||
|
|
||
| return buffer; | ||
| } | ||
|
JoasE marked this conversation as resolved.
|
||
| } | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,33 @@ | ||
| // Licensed to the .NET Foundation under one or more agreements. | ||
| // The .NET Foundation licenses this file to you under the MIT license. | ||
|
|
||
| using System.Diagnostics.CodeAnalysis; | ||
|
|
||
| namespace Microsoft.EntityFrameworkCore.Cosmos.Metadata.Internal; | ||
|
|
||
| /// <summary> | ||
| /// This is an internal API that supports the Entity Framework Core infrastructure and not subject to | ||
| /// the same compatibility standards as public APIs. It may be changed or removed without notice in | ||
| /// any release. You should only use it directly in your code with extreme caution and knowing that | ||
| /// doing so can result in application failures when updating to a new Entity Framework Core release. | ||
| /// </summary> | ||
| public static class TypeBaseExtensions | ||
| { | ||
| /// <summary> | ||
| /// This is an internal API that supports the Entity Framework Core infrastructure and not subject to | ||
| /// the same compatibility standards as public APIs. It may be changed or removed without notice in | ||
| /// any release. You should only use it directly in your code with extreme caution and knowing that | ||
| /// doing so can result in application failures when updating to a new Entity Framework Core release. | ||
| /// </summary> | ||
| public static bool TryGetOrdinalKey(this ITypeBase structuralType, [NotNullWhen(true)] out IProperty? ordinalKeyProperty) | ||
| { | ||
| if (structuralType is IEntityType entityType && entityType.IsOwned()) | ||
| { | ||
| ordinalKeyProperty = entityType.GetProperties().SingleOrDefault(x => x.IsOrdinalKeyProperty()); | ||
| return ordinalKeyProperty != null; | ||
| } | ||
|
|
||
| ordinalKeyProperty = null; | ||
| return false; | ||
| } | ||
| } |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.