Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 2 additions & 3 deletions lib/fluent/plugin/in_sql.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
28 changes: 28 additions & 0 deletions test/plugin/test_in_sql.rb
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,22 @@ def teardown
</table>
]

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
Expand Down Expand Up @@ -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.include?("schema_migrations") }
Comment thread
Watson1978 marked this conversation as resolved.
Outdated
ensure
d.instance.shutdown
end
end

def test_message
d = create_driver(CONFIG + "select_interval 1")
Message.create!(message: "message 1")
Expand Down