-
Notifications
You must be signed in to change notification settings - Fork 55
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix prepared_statement_bind_values to resolve nested event's fields (#76
) JDBC streaming filter uses the setting `prepared_statement_bind_values` to bind event's fields or constants to SQL prepared statements. It resolves fields with the notation `[field_name]` but it's not able to match the nested form: `[field][nested]`, this PR changes the match regexp to fix it.
- Loading branch information
Showing
4 changed files
with
28 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
23 changes: 23 additions & 0 deletions
23
spec/plugin_mixins/jdbc_streaming/parameter_handler_spec.rb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
# encoding: utf-8 | ||
require "logstash/devutils/rspec/spec_helper" | ||
require "logstash/plugin_mixins/jdbc_streaming/parameter_handler" | ||
|
||
|
||
describe LogStash::PluginMixins::JdbcStreaming::ParameterHandler do | ||
context "resolve field reference" do | ||
let(:event) { ::LogStash::Event.new("field" => "field_value") } | ||
|
||
it "should resolve root field" do | ||
handler = LogStash::PluginMixins::JdbcStreaming::ParameterHandler.build_bind_value_handler "[field]" | ||
handler.extract_from(event) | ||
expect(handler.extract_from(event)).to eq "field_value" | ||
end | ||
|
||
it "should resolve nested field" do | ||
event = ::LogStash::Event.from_json("{\"field\": {\"nested\": \"nested_field\"}}").first | ||
handler = LogStash::PluginMixins::JdbcStreaming::ParameterHandler.build_bind_value_handler "[field][nested]" | ||
handler.extract_from(event) | ||
expect(handler.extract_from(event)).to eq "nested_field" | ||
end | ||
end | ||
end |