diff --git a/lib/fluent/plugin/in_sql.rb b/lib/fluent/plugin/in_sql.rb index 2478bd1..f93d21d 100644 --- a/lib/fluent/plugin/in_sql.rb +++ b/lib/fluent/plugin/in_sql.rb @@ -219,11 +219,10 @@ def start nil else te = TableElement.new - te.configure({ + te.configure(Fluent::Config::Element.new('table', '', { 'table' => table_name, 'tag' => table_name, - 'update_column' => nil, - }) + }, [])) te end end.compact diff --git a/test/plugin/test_in_sql.rb b/test/plugin/test_in_sql.rb index ddb0db5..1ad29e8 100644 --- a/test/plugin/test_in_sql.rb +++ b/test/plugin/test_in_sql.rb @@ -30,6 +30,22 @@ def teardown ] + ALL_TABLES_CONFIG = %[ + adapter postgresql + host localhost + port 5432 + database fluentd_test + + username fluentd + password fluentd + + schema_search_path public + + tag_prefix db + + all_tables true + ] + def create_driver(conf = CONFIG) Fluent::Test::Driver::Input.new(Fluent::Plugin::SQLInput).configure(conf) end @@ -64,6 +80,18 @@ def test_configure assert_equal("logs", messages.tag) end + def test_all_tables + d = create_driver(ALL_TABLES_CONFIG) + d.instance.start + begin + table_names = d.instance.instance_variable_get(:@tables).map(&:table) + assert { table_names.include?("messages") } + assert { table_names.none? { |table_name| table_name.match?(Fluent::Plugin::SQLInput::SKIP_TABLE_REGEXP) }} + ensure + d.instance.shutdown + end + end + def test_message d = create_driver(CONFIG + "select_interval 1") Message.create!(message: "message 1")