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

Don't use sjson.GetTypeOfValue where it shouldn't be used #2728

Merged
merged 2 commits into from May 30, 2023

Conversation

noisersup
Copy link
Member

@noisersup noisersup commented May 29, 2023

Description

Readiness checklist

  • I added/updated unit tests.
  • I added/updated integration/compatibility tests.
  • I added/updated comments and checked rendering.
  • I made spot refactorings.
  • I updated user documentation.
  • I ran task all, and it passed.
  • I ensured that PR title is good enough for the changelog.
  • (for maintainers only) I set Reviewers (@FerretDB/core), Labels, Project and project's Sprint fields.
  • I marked all done items in this checklist.

@noisersup noisersup self-assigned this May 29, 2023
@noisersup noisersup added the code/chore Code maintenance improvements label May 29, 2023
@noisersup noisersup marked this pull request as ready for review May 29, 2023 12:56
@noisersup noisersup requested a review from a team as a code owner May 29, 2023 12:56
Copy link
Member

@AlekSi AlekSi left a comment

Choose a reason for hiding this comment

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

They happen to do the same thing.

sjson layer is responsible for preserving BSON-type information in storage. Currently, we store type information in the special schema field. For example, for "64-bit binary floating point" value, we store a string "double". That string could be replaced with a number or even a bitmask as long as we preserve backward compatibility for client applications (and not even that if we bump a major version).

Type aliases are fixed and cannot be changed without breaking compatibility with MongoDB.

What we need to do instead is:

  • make this difference clear from code doc comments;
  • check that we don't use a wrong function somewhere (spoiler: we do at least in once place)

@codecov
Copy link

codecov bot commented May 29, 2023

Codecov Report

Merging #2728 (04b41c2) into main (978278c) will decrease coverage by 36.85%.
The diff coverage is 0.00%.

Additional details and impacted files

Impacted file tree graph

@@             Coverage Diff             @@
##             main    #2728       +/-   ##
===========================================
- Coverage   63.04%   26.19%   -36.85%     
===========================================
  Files         441      441               
  Lines       22619    22619               
===========================================
- Hits        14260     5926     -8334     
- Misses       7434    16087     +8653     
+ Partials      925      606      -319     
Impacted Files Coverage Δ
internal/handlers/commonparams/typecode.go 48.42% <ø> (-43.16%) ⬇️
internal/handlers/pg/msg_dropindexes.go 0.00% <0.00%> (-88.10%) ⬇️
internal/handlers/sjson/schema.go 83.78% <ø> (ø)

... and 143 files with indirect coverage changes

Flag Coverage Δ
integration 4.96% <0.00%> (-51.54%) ⬇️
mongodb 4.96% <0.00%> (ø)
pg ?
unit 24.66% <0.00%> (ø)

Flags with carried forward coverage won't be shown. Click here to find out more.

@noisersup noisersup changed the title Remove sjson.GetTypeOfValue helper Don't use sjson.GetTypeOfValue where it shouldn't be used May 30, 2023
@AlekSi AlekSi enabled auto-merge (squash) May 30, 2023 13:04
@AlekSi AlekSi disabled auto-merge May 30, 2023 13:04
@AlekSi AlekSi enabled auto-merge (squash) May 30, 2023 13:04
Copy link
Member

@rumyantseva rumyantseva left a comment

Choose a reason for hiding this comment

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

👌

@AlekSi AlekSi merged commit f22f5e1 into FerretDB:main May 30, 2023
22 of 25 checks passed
@AlekSi AlekSi added this to the v1.3.0 milestone Jun 5, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
code/chore Code maintenance improvements
Projects
Archived in project
Development

Successfully merging this pull request may close these issues.

None yet

4 participants