-
Notifications
You must be signed in to change notification settings - Fork 10
refactor: rewrite trait Entity and friends so searching is reasonable [WPB-20839]
#1633
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
Draft
coriolinus
wants to merge
13
commits into
main
Choose a base branch
from
prgn/refactor/20839-new-entity-trait
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
istankovic
reviewed
Dec 1, 2025
| } | ||
|
|
||
| // About WASM Encryption: | ||
| // The store key (i.e. passphrase) is hashed using SHA256 to obtain 32 bytes |
Member
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 not the case anymore, since the database key type change clients have to provide the key directly .
Disable the `derive(Entity)` macro to a noop. I'm going to be doing some major refactoring of the `Entity` trait, and the noise of compiler errors due to implementations not matching the new definitions would absolutely drown out the signal of real problems, except for this. Obviously, we need to retain a real entity derive macro before this PR is over, but this should simplify things temporarily.
These traits should be both easier to use and more performant. One `set` method can't cover all desired cases: there may be some times when you want set-and-replace, and other times when you want set-if-absent. Since we're providing these with a blanket impl, there's no chance to just implement the desired semantics on your own type, particularly as there may be circumstances where you want both semantics for different occasions on the same entity.
These functions handle the boilerplate of a "standard" sql table.
d493f98 to
207b857
Compare
The existing `trait EntityEncryptionExt` was confusing: it depended on mutating the internal state, and never calling the appropriate methods too many or too few times. It wasn't obvious when or whether it was ever appropriate for an implementing item to override one of the default trait methods. In fairness, it's a complicated problem. This commit contains my approach, which breaks it up substantially. Entities no longer implement `Serialize` or `Deserialize`, and in fact must not implement either of those. (If it were possible, I'd have added negative trait bounds to that effect.) Doing this with separate types gives us some static type safety, which is always nice! Instead, entities which want to serialize must implement `Encrypting`, which requires them to copy all non-sensitive data and encrypt all sensitive data into an associated type. This associated type implements `Serialize`. Likewise, entities which want to deserialize must implement `Decrypting`, which requires them to copy all non-sensitive data and decrypt all sensitive data from an associated type. This associated type implements `Deserialize`. The benefit is that required methods have no defaults, and it is impossible to improperly override default methods. There are now helper traits `EncryptData` and `DecryptData`, which are automatically implemented for all entities, and handle all the details of the symmetrical encryption and decryption.
207b857 to
e7a3c21
Compare
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
What's new in this PR
PR Submission Checklist for internal contributors
SQPIT-764feat(conversation-list): Sort conversations by most emojis in the title #SQPIT-764.