-
-
Notifications
You must be signed in to change notification settings - Fork 1.3k
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
[FEAT identifiers] adds flagged public API and integration tests #6272
Conversation
01f583e
to
24bab59
Compare
packages/store/addon/-private/system/store/record-data-store-wrapper.ts
Outdated
Show resolved
Hide resolved
packages/store/addon/-private/ts-interfaces/ember-data-json-api.ts
Outdated
Show resolved
Hide resolved
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
reviewed under @runspired account. seems good after comments addressed and @mike-north 👍
9495201
to
5937fc4
Compare
still working on reviewing this |
packages/-ember-data/tests/integration/identifiers/lid-reflection-test.ts
Show resolved
Hide resolved
packages/-ember-data/tests/integration/identifiers/configuration-test.ts
Show resolved
Hide resolved
packages/-ember-data/tests/integration/identifiers/configuration-test.ts
Show resolved
Hide resolved
packages/-ember-data/tests/integration/identifiers/configuration-test.ts
Show resolved
Hide resolved
packages/-ember-data/tests/integration/identifiers/configuration-test.ts
Show resolved
Hide resolved
packages/-ember-data/tests/integration/identifiers/configuration-test.ts
Show resolved
Hide resolved
packages/-ember-data/tests/integration/identifiers/lid-reflection-test.ts
Show resolved
Hide resolved
let store; | ||
let calls; | ||
let secondaryCache: { | ||
id: Dict<string, string>; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
When did the Dict
type get changed to allow two typeparams? ({ [KK in K]: V; }
). It's now not really a dictionary (arbitrary keys) and matches nearly exactly with the built-in Record<K, V>
utility type.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Great catch for two reasons:
-
I was not aware of
Record<K, V>
being a built-in type and that explains why I've sometimes found that definition trying to trump our own definedRecord
type. -
As far as I can recall this was the
Dict
we introduced together a while back. I'll make a cleanup pass to refactor toDict<ValueType>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
(said cleanup pass will be separate from this PR as Dict
has this <K, V>` usage more broadly)
if (internalModel) { | ||
internalModel.destroyFromRecordData(); | ||
} | ||
} | ||
} | ||
|
||
function hasValidId(id?: string | null, clientId?: string | null): id is string { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is a questionable type guard, and if misused could result in some "lying" in the type-checker. There's a significant difference between the static analysis behavior
"true if id is a string"
and the runtime behavior
"true unless both id and clientId are truthy"
We should take a close look at this before merging the PR
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We've looked at this together before. It's basically a "caught between a rock and a hard place" situation where method signature overloads don't "fall through" to calls to other methods with similar signatures. Here's an example https://typescript-play.js.org/#code/GYVwdgxgLglg9mABAEzgdQBQEMAqALGMAcwC5EBnKAJ0KIBpEsw4o8BTK-Wsym4xAD6IwIADaiAlGQBucGMgDcAKFCRYCFOmxdiParUHCxohkxbtOBXRX3EpiWfOWro8JKky4rpG3yKGRcVNmVg4dH14DIUDJGTlkRABvAF8lFXBXDVQADW1vPT9g8zD83yijcXtHRXS1N01cr24y-mjjItDLZsi7OKdazPc4RvCC8piOi1GW-zbKvoTEpUQVxAB6NcQOKjgqckQAIzYILBByNkZwxBh9gAMe2YrRW+XVqjYoECohz3DJktoEmUqQG6iGAE08t1bPRGCEpqUHgFjFV4s4MmDNJCmtYkXMTHDil1cTDUf0XJjUNjpninv9iREYcj5g54klXqsNogAEQAd12AGtyNyOYh3p9vppft5GPsHvTwkClCCKfVUAAtKEkwqEzo0pn4sk1VVZOCanGMvzMglmPWI0kLdF1U3m-VW-EK+3up5G9mrdabPmC4Wi8VfH5a2G2hEGLBy0nAtJcoNUIXcw4gKDCOC8xiIUQsRBwYCICBULAALwAnqX2BAhYx3tnc+8AI4gGDvBKERBQBD7YuIAC2HzwcGQ5CUXN57CQ3IQF0HoXOve8+yOsZm6d5cYcWFE8iwUDYCSw+YQ-lgI8ObGAuzYoLVcAAwuXq8+60LI2NiJ7od6YiNJ1Bk0V9KyrD9ji-C0f0eCZdRjbVAUdR9TTA99P3Ib8ZmtP8kNaH0Fj9VYYBLbB4QBfgAEIAF4aJ9Yj-TDSUPEjPCiCVf1ki2UQV1IxBI0QWj6MAxi3g+cMpTYhDKI45QuJ4lcln9FYuTANhpA4UUVlYHZc3U3MAFEqB2KgMFuAA5DSOFuTjVlSf1lSAA
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would also note that the near-term solution for not needing this craziness is to continue refactoring towards use of identifiers
. Because identifiers are typed as a union of these two cases (one or the other must be a string) we reduce the number of method overloads and pass the "overloaded" type signature around with the value instead.
5937fc4
to
2028505
Compare
2 test failures to investigate, only one blocking
|
Fantastic @runspired! ❤️ |
resolves #6170
closes #6171
Duplicate records on save (mostly already closed in favor of 1829)
resolves #1726
resolves #1829
resolves #4262
resolves #5083
resolves #5237
resolves #4972
resolves adopted-ember-addons/ember-data-model-fragments#221
resolves emberjs/rfcs#173
resolves #4552
STI / Polymorphism
resolves #2407
resolves #4377
Forum
resolves https://discuss.emberjs.com/t/proposal-fix-saving-new-embedded-records-creates-duplicates/3677/17
Once relationships are refactored such that they are managed by identifier as well there's another long list to close :)