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

Fix parsing of Bindings with Escaped Numbers #533

Merged
merged 7 commits into from
Nov 7, 2024

Conversation

KetanReddy
Copy link
Member

Change Type (required)

Indicate the type of change your pull request is:

  • patch
  • minor
  • major

Does your PR have any documentation updates?

  • Updated docs
  • No Update needed
  • Unable to update docs

@KetanReddy KetanReddy added the patch Increment the patch version when merged label Oct 25, 2024
@KetanReddy KetanReddy requested a review from adierkens as a code owner October 25, 2024 23:01
@KetanReddy KetanReddy marked this pull request as draft October 25, 2024 23:02
@@ -162,6 +162,16 @@ describe("errors", () => {
);
});

test("works for bindings with escaped numeric bindings", () => {
Copy link
Member

Choose a reason for hiding this comment

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

Can we add more test cases for this to the list?

Copy link
Member

Choose a reason for hiding this comment

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

},
});

expect(parser.parse("foo['01'].baz").asString()).toBe("foo.01.baz");
Copy link
Member

Choose a reason for hiding this comment

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

Do we need to handle cases for parser.parse('foo.01.baz')? Does that also parse to a string instead of an int?

Copy link
Member Author

Choose a reason for hiding this comment

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

Good question. Current behavior is that would parsed as an integer and we should probably keep that behavior. that does mean the parsing of that binding needs to probably happen a bit differently than it is now because the context of if a segment was wrapped in the escape syntax doesn't make it down to the binding constructor.

Copy link
Member

Choose a reason for hiding this comment

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

👍 let's make sure we have tests for foo.01.baz and foo[01].baz to make sure we maintain existing behavior to be safe

@KetanReddy KetanReddy linked an issue Oct 31, 2024 that may be closed by this pull request
@KetanReddy KetanReddy force-pushed the bugfix/bindings-with-escaped-numbers branch from f7b5e84 to 6b2aa5c Compare November 4, 2024 19:37
@KetanReddy
Copy link
Member Author

Benchmark Results

Main

     name                                                              hz     min     max    mean     p75     p99    p995    p999     rme  samples
   · Resolving binding: foo.bar                              2,691,434.62  0.0002  1.6159  0.0004  0.0004  0.0005  0.0008  0.0042  ±0.69%  1345718   fastest
   · Resolving binding: foo.pets.1.name                      1,586,941.64  0.0005  0.1851  0.0006  0.0006  0.0009  0.0014  0.0047  ±0.55%   793471
   · Resolving binding: foo.pets.01.name                     1,615,464.79  0.0005  1.2965  0.0006  0.0006  0.0008  0.0009  0.0041  ±0.67%   807733
   · Resolving binding: foo.pets['01'].name                  1,393,435.04  0.0005  0.2489  0.0007  0.0007  0.0010  0.0012  0.0044  ±0.52%   696718
   · Resolving binding: foo.pets[name = "frodo"].type          883,283.53  0.0009  0.1507  0.0011  0.0011  0.0014  0.0015  0.0043  ±0.37%   441642
   · Resolving binding: foo.pets["name" = "sprinkles"].type    662,663.86  0.0012  0.1624  0.0015  0.0015  0.0019  0.0020  0.0110  ±0.39%   331332   slowest

Branch

     name                                                              hz     min     max    mean     p75     p99    p995    p999     rme  samples
   · Resolving binding: foo.bar                              2,288,377.35  0.0003  3.1698  0.0004  0.0004  0.0009  0.0010  0.0150  ±1.39%  1144189   fastest
   · Resolving binding: foo.pets.1.name                      1,486,132.50  0.0005  0.1763  0.0007  0.0007  0.0009  0.0009  0.0033  ±0.44%   743067
   · Resolving binding: foo.pets.01.name                     1,443,449.15  0.0005  0.2372  0.0007  0.0007  0.0009  0.0009  0.0042  ±0.43%   721725
   · Resolving binding: foo.pets['01'].name                  1,288,582.27  0.0006  0.1599  0.0008  0.0008  0.0010  0.0010  0.0044  ±0.39%   644292
   · Resolving binding: foo.pets[name = "frodo"].type          848,121.04  0.0010  0.2123  0.0012  0.0011  0.0015  0.0017  0.0090  ±0.41%   424061
   · Resolving binding: foo.pets["name" = "sprinkles"].type    648,869.75  0.0013  0.2001  0.0015  0.0015  0.0019  0.0023  0.0113  ±0.40%   324435   slowest

Definitely some impact on performance overall but not sure if that can be avoided

@KetanReddy KetanReddy changed the title [WIP] Fix parsing of Bindings with Escaped Numbers Fix parsing of Bindings with Escaped Numbers Nov 5, 2024
@KetanReddy KetanReddy marked this pull request as ready for review November 5, 2024 00:09
Copy link

codecov bot commented Nov 5, 2024

Codecov Report

Attention: Patch coverage is 53.33333% with 7 lines in your changes missing coverage. Please review.

Project coverage is 89.57%. Comparing base (0fb5a67) to head (a236f03).
Report is 12 commits behind head on main.

Files with missing lines Patch % Lines
vitest.config.ts 0.00% 5 Missing ⚠️
core/player/src/binding-grammar/custom/index.ts 80.00% 2 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main     #533      +/-   ##
==========================================
- Coverage   91.88%   89.57%   -2.31%     
==========================================
  Files         341      331      -10     
  Lines       27303    19718    -7585     
  Branches     1944     1949       +5     
==========================================
- Hits        25087    17663    -7424     
+ Misses       2202     2041     -161     
  Partials       14       14              

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
patch Increment the patch version when merged
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Escaping Numbers with a Leading 0 Does Not Work
3 participants