Static Filter: support multiple positional parameters #81
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.
When multiple
prepared_parameters
are passed to the local lookup, the Sequel library raises an exception withMismatched number of placeholders
even when the provided query has the correct number of placeholders. Our unit specs stub out the prepared statement details and therefore do not show off the issue.There is a workaround listed at the end of this Issue.
This PR introduces a failing spec showing the behaviour when
query => "SELECT * FROM servers WHERE ip = ? AND name = ?"
prepared_parameters => ["[host][ip]", "[host][name]"]
"host" : { "ip" : "10.3.1.1", "name" : "mv-server-1"}, "message" : "ping"}
Workaround
Instead of using prepared statements and
positional_parameters
, it is safe to use a regular query with named placeholders and theparameters
option, as demonstrated by a companion integration spec in this PR:query => "SELECT * FROM servers WHERE ip = :host_ip AND name = :host_name"
prepared_parameters => {"host_ip" => "[host][ip]" "host_name" => "[host][name]" }
"host" : { "ip" : "10.3.1.1", "name" : "mv-server-1"}, "message" : "ping"}