Skip to content

fix(repository): implement missing add & replace methods#58

Merged
kiaking merged 4 commits intomasterfrom
fix-missing-insert-methods
Apr 17, 2021
Merged

fix(repository): implement missing add & replace methods#58
kiaking merged 4 commits intomasterfrom
fix-missing-insert-methods

Conversation

@cuebit
Copy link
Copy Markdown
Member

@cuebit cuebit commented Apr 17, 2021

This PR implements the repository's add and replace methods that happen to be missing but are documented.

Type of PR:

  • Bugfix
  • Feature
  • Refactor
  • Code style update
  • Build-related changes
  • Test
  • Documentation
  • Other, please describe:

Breaking changes:

  • No
  • Yes

@cuebit cuebit added the bug Something isn't working label Apr 17, 2021
@cuebit cuebit added this to the v1.0.0-alpha.1 milestone Apr 17, 2021
@cuebit cuebit requested a review from kiaking April 17, 2021 10:29
@cuebit cuebit self-assigned this Apr 17, 2021
@codecov
Copy link
Copy Markdown

codecov bot commented Apr 17, 2021

Codecov Report

Merging #58 (2fbafa9) into master (44c4303) will not change coverage.
The diff coverage is 100.00%.

Impacted file tree graph

@@            Coverage Diff            @@
##            master       #58   +/-   ##
=========================================
  Coverage   100.00%   100.00%           
=========================================
  Files           36        36           
  Lines          823       824    +1     
  Branches       132       131    -1     
=========================================
+ Hits           823       824    +1     
Impacted Files Coverage Δ
src/model/Model.ts 100.00% <100.00%> (ø)
src/query/Query.ts 100.00% <100.00%> (ø)
src/repository/Repository.ts 100.00% <100.00%> (ø)
src/schema/Schema.ts 100.00% <100.00%> (ø)

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 44c4303...2fbafa9. Read the comment docs.

@cuebit
Copy link
Copy Markdown
Member Author

cuebit commented Apr 17, 2021

Methods such as insert, fresh, etc, all normalize the records and null indexes are successfully asserted. Since the aforementioned assertion takes place in the Schema class, non-normalized records will always return null for missing indexes. This means non-normalizing persist methods, such as add, replace, etc, will not throw in the absence of a key, particularly in the case for composite keys which results in inconsistent behavior.

@kiaking in this regard, unless this is expected behavior, can you think of any side-effects of moving this assertion to the $getIndexId() method?

@kiaking
Copy link
Copy Markdown
Member

kiaking commented Apr 17, 2021

Oh yeah this is not expected behavior. The null id should always throw unless it's set as UID.

And yeah I think it makes sense to move the assertion to the $getIndexId() method! Would you like to include that in the PR?

@cuebit cuebit marked this pull request as ready for review April 17, 2021 12:12
@cuebit cuebit added the enhancement New feature or request label Apr 17, 2021
@kiaking kiaking merged commit 09496aa into master Apr 17, 2021
@kiaking kiaking deleted the fix-missing-insert-methods branch April 17, 2021 12:18
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants