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.
Hiya @magnusvk 👋 Thanks for this great gem.
In my project, my Postgres database uses binary ULIDs—they deserialize as strings, but are stored as binary data.
I noticed that my foreign key counters stopped working, and I tracked it down to the one line change in this PR. There are a couple of problems with the
"#{klass.table_name}.#{relation_primary_key(first, source: obj, was: was)} = ?"
format, the biggest being that the value is not quoted, which can cause security problems. Instead, we can lean heavily intowhere
figuring out all the details for communicating with the database.While grepping around, I found two other places (1, 2) where this exact pattern is used, rather than
#{string} = ?
. That plus the passing tests gives me confidence that this is a safe change to make.