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.
Hello!
I'm using goqu with MySQL dialect.
Problem description: If you make detailed Dataset (using Where) from base Dataset, already having some where clauses, sometimes added expressions could be presented in the base dataset or its derivatives.
For example:
This happens because of go append() behaviour - in expressionList.Append() it may return reallocated slice (and everything goes well) or slice at the same address (then shit could happens if another Dataset already using same physical memory to store its own expression). To prevent this you should always reallocate slice.
I have implemented this fix and added test case.
Alternatively you could build base Dataset for every subset, but this will produce excessive and hardly maintainable code. Also you can generate sql for one dataset at a time, but this won't work if you want to make Union or another combination.
Best regards,
Anton Kriukov.