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

Persist Id values into owned collection JSON documents #34466

Merged
merged 2 commits into from
Aug 20, 2024
Merged

Conversation

ajcvickers
Copy link
Contributor

Fixes #29380

There are several aspects to #29380:

I investigated persisting key values, but identity lookup requires key values in the materializer before we do the parsing of the document. This means persisted key values are not available without re-writing this part of the shaper, which we can't do for 9.

To fix the main issue (round-trip Id) this PR changes the way identity on owned JSON collection documents works. Instead of discovering and using the Id property, we treat it like any other property. We then create a shadow __synthesizedOrdinal property to act as the ordinal part of the key.

We need to discuss:

  • Is this breaking for any scenario that was working before?
  • Does this put us in a bad place for the future of owned types with explicit keys?

@ajcvickers ajcvickers requested a review from a team August 19, 2024 16:41
@AndriySvyryd
Copy link
Member

Did you mean to target release/9.0?

Copy link
Member

@AndriySvyryd AndriySvyryd left a comment

Choose a reason for hiding this comment

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

Throw in validation for persisted keys in JSON

@ajcvickers
Copy link
Contributor Author

Did you mean to target release/9.0?

No, I meant to merge into main and backport. I'm still not sure what the bar is or how it will be measured, so I didn't want to be left with another PR I can't merge--looking at you, code cleanup! :-D

Fixes #29380

There are several aspects to #29380:
- Constructor binding (already fixed)
- Round-tripping the `Id` property value (addressed by this PR)
- Persisting key values in JSON collection documents (tracked by #28594)

I investigated persisting key values, but identity lookup requires key values in the materializer before we do the parsing of the document. This means persisted key values are not available without re-writing this part of the shaper, which we can't do for 9.

To fix the main issue (round-trip `Id`) this PR changes the way identity on owned JSON collection documents works. Instead of discovering and using the `Id` property, we treat it like any other property. We then create a shadow `__synthesizedOrdinal` property to act as the ordinal part of the key.

We need to discuss:
- Is this breaking for any scenario that was working before?
- Does this put us in a bad place for the future of owned types with explicit keys?
@ajcvickers ajcvickers merged commit 24668ff into main Aug 20, 2024
7 checks passed
@ajcvickers ajcvickers deleted the NotMyKey branch August 20, 2024 13:45
ajcvickers added a commit that referenced this pull request Aug 20, 2024
* Persist `Id` values into owned collection JSON documents

Fixes #29380

There are several aspects to #29380:
- Constructor binding (already fixed)
- Round-tripping the `Id` property value (addressed by this PR)
- Persisting key values in JSON collection documents (tracked by #28594)

I investigated persisting key values, but identity lookup requires key values in the materializer before we do the parsing of the document. This means persisted key values are not available without re-writing this part of the shaper, which we can't do for 9.

To fix the main issue (round-trip `Id`) this PR changes the way identity on owned JSON collection documents works. Instead of discovering and using the `Id` property, we treat it like any other property. We then create a shadow `__synthesizedOrdinal` property to act as the ordinal part of the key.

We need to discuss:
- Is this breaking for any scenario that was working before?
- Does this put us in a bad place for the future of owned types with explicit keys?

* Added validation of no explicit keys
ajcvickers added a commit that referenced this pull request Aug 21, 2024
* Persist `Id` values into owned collection JSON documents

Fixes #29380

There are several aspects to #29380:
- Constructor binding (already fixed)
- Round-tripping the `Id` property value (addressed by this PR)
- Persisting key values in JSON collection documents (tracked by #28594)

I investigated persisting key values, but identity lookup requires key values in the materializer before we do the parsing of the document. This means persisted key values are not available without re-writing this part of the shaper, which we can't do for 9.

To fix the main issue (round-trip `Id`) this PR changes the way identity on owned JSON collection documents works. Instead of discovering and using the `Id` property, we treat it like any other property. We then create a shadow `__synthesizedOrdinal` property to act as the ordinal part of the key.

We need to discuss:
- Is this breaking for any scenario that was working before?
- Does this put us in a bad place for the future of owned types with explicit keys?

* Added validation of no explicit keys
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.

Columns with name "Id" in JSon object causes System.ArgumentException in materialization
2 participants