Skip to content

DOCSP-25723 Updates to Mutually Recursive Schema Types #459

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

Conversation

ajhuh-mdb
Copy link
Collaborator

@ajhuh-mdb ajhuh-mdb commented Dec 1, 2022

Pull Request Info

PR Reviewing Guidelines

Notes

  • Original ticket mentions broad support for recursive schema types, but the original Node PR only reflects changes for mutually recursive schema types
  • Changes to be made were discussed in this Slack thread due to incorrectly documented behavior/examples in the Node release notes.

JIRA
https://jira.mongodb.org/browse/DOCSP-25723

Staging

Self-Review Checklist

  • Is this free of any warnings or errors in the RST?
  • Did you run a spell-check?
  • Did you run a grammar-check?
  • Are all the links working?


.. _node-driver-recursive-types-dot-notation:

Recursive Types and Dot Notation
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

.. important:: Impacted Versions

- 4.3
Copy link
Collaborator Author

@ajhuh-mdb ajhuh-mdb Dec 1, 2022

Choose a reason for hiding this comment

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

Removed this admonition since this affects nested recursive types from all versions after v4.3.1

Copy link
Collaborator

Choose a reason for hiding this comment

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

Question: I thought v4.11 fixed this issue. What am I missing?

Copy link
Collaborator Author

@ajhuh-mdb ajhuh-mdb Dec 2, 2022

Choose a reason for hiding this comment

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

Ah so the "fix" I meant to refer to when we met was not type safety.

For clarification, the "issue" from 4.3.0 was that, previously, just the presence of a self-referential recursive schema type at all would cause a compilation error. The "fix" in 4.3.1 is that they allowed for the code to compile with a recursive schema type present, but their solution, in doing so, couldn't guarantee type checking (which becomes a separate "issue" from the one originally mentioned).

Sorry about that confusion 😅

TypeScript.
The 4.11 {+driver-short+} release includes added support for **mutually
recursive** collection schema types. The driver also provides type safety for
dot notation queries up to a depth of eight in this release. Typescript compiles
Copy link
Collaborator Author

@ajhuh-mdb ajhuh-mdb Dec 1, 2022

Choose a reason for hiding this comment

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

v4.11 release notes say nine, but tests of original PR say eight

Copy link
Collaborator

Choose a reason for hiding this comment

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

Same comment as above--confirm this with devs

name: string;
}

The {+driver-short+} provides type safety for mutually recursive types
referenced through dot notation up to a depth of eight. The following code
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

v4.11 release notes say nine, but tests of original PR say eight

Copy link
Collaborator

Choose a reason for hiding this comment

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

Definitely worth confirming with the devs

Copy link
Collaborator

Choose a reason for hiding this comment

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

The tests are correct, I'll be updating the notes

Copy link
Collaborator

@mongoKart mongoKart left a comment

Choose a reason for hiding this comment

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

great job! reading through this helps me understand the subject (which i couldn't get my head around an hour ago) much better. i made some suggestions for clarity since this is weirdo technical stuff and we should be super precise. feel free to edit my suggestions as you see fit!


.. _node-driver-recursive-types-dot-notation:

Recursive Types and Dot Notation
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

.. important:: Impacted Versions

- 4.3
Copy link
Collaborator

Choose a reason for hiding this comment

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

Question: I thought v4.11 fixed this issue. What am I missing?

Comment on lines 78 to 80
In versions 4.3 through 4.10 of the {+driver-short+}, you cannot specify a
**mutually recursive** type as a type parameter. To specify a mutually
recursive type as a type parameter, use version 4.11 or newer.
Copy link
Collaborator

Choose a reason for hiding this comment

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

Issue: I think we can remove the version note if you're going to do a separate PR for versions 4.3-4.10. To me, it's implied that older versions of a driver might not be able to do things a new version would do.

Suggestion: Delete these lines, then make "mutually recursive" bold on line 82.

Copy link
Collaborator Author

@ajhuh-mdb ajhuh-mdb Dec 2, 2022

Choose a reason for hiding this comment

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

While I do agree, I'm starting to skew towards keeping it. Just thinking of the case where a user using an older version (e.g. v4.3) goes to our docs site (which defaults to the current version v4.12) and sees the incorrect information without realizing they're on the incorrect version of the docs. Not sure if this is too much of an edge case, though... I'll likely bring it up as a q in #textual-dbx to get others' thoughts.

Copy link
Collaborator

Choose a reason for hiding this comment

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

Makes sense. I'm good with whatever the team decides.

name: string;
}

The {+driver-short+} provides type safety for mutually recursive types
referenced through dot notation up to a depth of eight. The following code
Copy link
Collaborator

Choose a reason for hiding this comment

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

Definitely worth confirming with the devs

Comment on lines 69 to 70
dot notation queries up to a depth of eight in this release. Typescript compiles
your code beyond a depth of eight, but types fall back to ``any`` at this level.
Copy link
Collaborator

Choose a reason for hiding this comment

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

Issue: Somewhat confusing

Suggestion:

Suggested change
dot notation queries up to a depth of eight in this release. Typescript compiles
your code beyond a depth of eight, but types fall back to ``any`` at this level.
dot notation queries up to a depth of eight in this release. At a depth greater than or equal to eight, all dot-notation properties on recursive types are assigned the ``any`` type.

(Is "properties" the right word here?)

Copy link
Collaborator Author

@ajhuh-mdb ajhuh-mdb Dec 2, 2022

Choose a reason for hiding this comment

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

I think the important thing for users to know here is that their code won't deal with a compilation error, rather than knowing the specifics of what type they'll fall back to.

The bit about the any type assignment is more so for users to know why they won't run into a compilation error. Will try to restructure the sentence to mitigate confusion

@ajhuh-mdb
Copy link
Collaborator Author

ajhuh-mdb commented Dec 2, 2022

Hi @nbbeeken and @baileympearson 👋

Whenever y'all get a chance, could I a technical review on these documentation edits referencing the changes made in NODE-3875?

Mainly looking for:

  1. Technical accuracy.
  2. Consistency/alignment between these docs, the v4.11 release notes on GH, the original PR, and anywhere else that may reference these behavior changes.

Thanks!

Copy link
Collaborator

@mongoKart mongoKart left a comment

Choose a reason for hiding this comment

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

LGTM once the team agrees on that admonition

Copy link
Collaborator

@nbbeeken nbbeeken left a comment

Choose a reason for hiding this comment

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

LGTM, one small syntax fix just to get the highlighting working

@mongoKart mongoKart merged commit 72be9c1 into mongodb:master Dec 5, 2022
jordan-smith721 pushed a commit that referenced this pull request Dec 5, 2022
* DOCSP-25723 Updates to Mutually Recursive Schema Types

* edit mutually recursive pet code block

* edit collection schema name

* more specific limitations menu text

* MW comment edits

* rephrase confusing sentence

* remove warning notes for v4.3-4.10 behavior

* Apply suggestions from code review

Co-authored-by: Neal Beeken <[email protected]>

Co-authored-by: Mike Woofter <[email protected]>
Co-authored-by: Neal Beeken <[email protected]>
(cherry picked from commit 72be9c1)
jordan-smith721 pushed a commit that referenced this pull request Dec 5, 2022
* DOCSP-25723 Updates to Mutually Recursive Schema Types

* edit mutually recursive pet code block

* edit collection schema name

* more specific limitations menu text

* MW comment edits

* rephrase confusing sentence

* remove warning notes for v4.3-4.10 behavior

* Apply suggestions from code review

Co-authored-by: Neal Beeken <[email protected]>

Co-authored-by: Mike Woofter <[email protected]>
Co-authored-by: Neal Beeken <[email protected]>
(cherry picked from commit 72be9c1)
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.

3 participants