Fix potential name collisions in code generated by the table!
macro
#3146
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 commit fixes potential name collisions in code generated by the
table!
macro by prefixing function argument names with__diesel_internal
. The underlying problem here is that rust acceptspatterns as part of the function signature. This combined with the fact
that each zero sized struct (so all column/table structs) are type +
value at the same time results in problems as soon as the users tries to
create a column/table with the same name as one of the used arguments.
So for example if the users has a table that contains an
alias
column,that would have caused a name collision inside of the following function
signature:
Rustc would have interpreted
alias
here as zero sized struct literal,which of course has a different type than the corresponding RHS. That
results in a compiler error about mismatched types.
This commit fixes this problem by prefixing the corresponding variables
with
__diesel_internal
, which is hopefully reasonably uncommon, sothat no one uses that as column name prefix.