Skip to content

fix: support number ID field generation in StubDatabaseAdapter#43

Merged
wschurman merged 2 commits intomasterfrom
@wschurman/stub-number-ids
Jun 10, 2020
Merged

fix: support number ID field generation in StubDatabaseAdapter#43
wschurman merged 2 commits intomasterfrom
@wschurman/stub-number-ids

Conversation

@wschurman
Copy link
Copy Markdown
Member

Why

Most entities we have internally at Expo use UUID keys, so this was the default for StubDatabaseAdapter. Supporting number keys is a requirement for most auto-increment systems.

Closes #41.

How

Randomly generate a random number if the type of the ID field is a number. Decided to do random rather than simulating auto-increment as it's simpler.

Test Plan

Run new test with yarn test.

@wschurman wschurman requested a review from quinlanj June 10, 2020 19:23
@codecov
Copy link
Copy Markdown

codecov bot commented Jun 10, 2020

Codecov Report

Merging #43 into master will increase coverage by 0.04%.
The diff coverage is 100.00%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master      #43      +/-   ##
==========================================
+ Coverage   93.78%   93.82%   +0.04%     
==========================================
  Files          55       55              
  Lines        1320     1329       +9     
  Branches      158      146      -12     
==========================================
+ Hits         1238     1247       +9     
  Misses         81       81              
  Partials        1        1              
Flag Coverage Δ
#integration 93.82% <100.00%> (+0.04%) ⬆️
#unittest 93.82% <100.00%> (+0.04%) ⬆️
Impacted Files Coverage Δ
...es/entity/src/utils/testing/StubDatabaseAdapter.ts 89.41% <100.00%> (+1.25%) ⬆️
packages/entity/src/EntityPrivacyPolicy.ts 96.61% <0.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 d25c1e1...bd68776. Read the comment docs.

Copy link
Copy Markdown
Member

@quinlanj quinlanj left a comment

Choose a reason for hiding this comment

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

lgtm, thanks!

import AlwaysAllowPrivacyPolicyRule from '../rules/AlwaysAllowPrivacyPolicyRule';

export type DateIDTestFields = {
id: Date;
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

lol

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

the funny thing is that Date ids are probably not uncommon since they're fairly unique given enough precision.

@wschurman wschurman merged commit 60cc0fb into master Jun 10, 2020
@wschurman wschurman deleted the @wschurman/stub-number-ids branch June 10, 2020 22:09
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.

Support non-string IDs in StubDatabaseAdapter

2 participants