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 plusType for schema that contains only ISL 2.0 version marker #306

Merged
merged 1 commit into from
Feb 20, 2024

Conversation

popematt
Copy link
Contributor

@popematt popematt commented Feb 20, 2024

Issue #, if available:

Fixes #305
Also related to #304

Description of changes:

There was incorrect logic for handling appending a new type to a schema in SchemaImpl_2_0.plusType(). The idx == isl.lastIndex meant that the new type would be inserted before the last value, no matter what it was. So, when the existing schema had only one top-level value (in this case, the $ion_schema_2_0 version marker), the new type would be inserted before the version marker, which is illegal.

Now, the logic for adding the type in plusType() is as follows:

  1. If we find a type with the same name, replace it with the new type
  2. If we find a schema footer, insert the new type immediately before the schema footer
  3. Otherwise, append to the very end of the existing schema.

(This is what it was intended to be all along.)

Related PRs in ion-schema, ion-schema-tests, ion-schema-schemas:
None

By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.

Copy link

codecov bot commented Feb 20, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Comparison is base (bbab678) 83.18% compared to head (d6aa6d1) 83.24%.

Additional details and impacted files
@@            Coverage Diff             @@
##           master     #306      +/-   ##
==========================================
+ Coverage   83.18%   83.24%   +0.05%     
==========================================
  Files         160      160              
  Lines        3777     3777              
  Branches      907      907              
==========================================
+ Hits         3142     3144       +2     
  Misses        360      360              
+ Partials      275      273       -2     

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

@popematt popematt merged commit 7a9ee6d into amazon-ion:master Feb 20, 2024
5 checks passed
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.

Empty SchemaImpl_2_0 throws exception when calling plusType()
2 participants