Draft
Conversation
jayvdb
commented
Jul 31, 2023
| Self::new() | ||
| let obj = Faker.fake::<T>(); | ||
| let ret = Self::new(); | ||
| ret.all_values.set(vec![obj]).ok(); |
Collaborator
Author
There was a problem hiding this comment.
Values in all_values are presumed to be already saved, and thus not savable.
The only way I can think to get this working is: a pub fn which loads from the db, and compares it with all parts of this Many to determine which DML is needed to "sync" to the db. This could be of value if there are multiple threads, and the current thread wants to make its version of the Many<T> to be authoritative, despite changes that other threads may have made to the same Many<T>. There are several minefields down that path.
jayvdb
commented
Jul 31, 2023
| Self::new_raw() | ||
| /// A dummy value for T will be created, however it also has to have the Clone | ||
| /// trait in order for the mutable value to be obtained so that it can be saved. | ||
| impl<T: DataObject + Dummy<Faker>> Dummy<Faker> for ForeignKey<T> { |
Collaborator
Author
There was a problem hiding this comment.
If we proceed with this, and .clone() is needed to get the T to be saved, IMO we should do:
-impl<T: DataObject + Dummy<Faker>>...
+impl<T: Clone + DataObject + Dummy<Faker>>...and then document how to save the fake data.
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
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.
This is a demo of
ForeignKey<T>looks doable, but requiresT: Clonein order for the fakeTto be stored in the dbMany<T>looks to be incompatible with howManyis designedI think it is worthwhile to generate a fake value for
ForeignKey<T>, if only because faking withSelf::new_raw()is really bad, because it exposes an invalid state that can not otherwise easily be reached.