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.
A common issue we've found with the query builder is the lack of escapes within string conditions and functions. This means we can't reliably identify column/table names in order to effectively quote them.
So this feature implements a "post effect" within the query builder that extracts and replaces any matching table 'identifiers' registered with the query object, i.e. from + join tables. It's surprisingly effective and gives us a small edge on safety.
This feature is actually ripped directly from Chris' work here. Fingers crossed he's cool with that ;)
It's important to remember that is a syntax safety feature, not a user-input sanitizing feature. Field names must always be explicitly validated if they come from an untrusted source.
Example
As seen in the tests (w/ sqlite quoting rules).
From this query the identifier are:
stuff
mmm
(aliased frommore
)Without quoting.
Note that prefixes, aliases, and
buildClause()
still perform their usual quoting rules.With quoting.
Note that
missing.count
is ignored because it's not a registered table identifier. That said, the query would fail anyway.