fix: EXPOSED-694 Entities insertion could fail if batches have different column sets #2365
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.
Description
If there are multiple entities that have different set of columns inside
writeValues
the flush of these entities could fail. The reason is the batch insert that will have different column sets for different entities.It happens if the
id
field of that entity has client side default value. Otherwise entity'swriteValues
will be extended with default values insideEntityClass::new()
. Actually, the check for that extending looks suspicious and has the following form:As I can see (according to the tests) that extending is needed to prevent multiple reads of default values from the table object.
Solution: at the current moment I solved the problem on the step of creating batch insert for the new entities. Entities could be partitioned by column sets to prevent inconsistent batch inserts. In the worst case it could lead to insertion entities one-by-one. But in the case of small amount of columns and large amount of entities it would not be a problem.
Type of Change
Please mark the relevant options with an "X":
Affected databases:
Related Issues
EXPOSED-694 Entities insertion could fail if batches have different column sets