lib/flydata/source_mysql/command/mysqldump.rb in flydata-0.7.5 vs lib/flydata/source_mysql/command/mysqldump.rb in flydata-0.7.6

- old
+ new

@@ -7,12 +7,35 @@ class Mysqldump < Sync include MysqlCommandBase def generate_command(dbconf, args) dbconf.delete('tables') - dbconf[:custom_option_end] = args.join(' ') + dbconf[:custom_option_end] = build_custom_option_end(args) dbconf[:command] = 'mysqldump' FlydataCore::Mysql::CommandGenerator::generate_mysql_cmd(dbconf) + end + + # Workaround to build --where options correctly + # + # [Background] + # Arguments including single/double quotations don't work because those quotations + # are removed from the system. + # + # User's command: + # flydata mysqldump table_a --where "id = 1001" + # ARGV: + # ["table_a", "--where", "id", "=", "1001"] + # + def build_custom_option_end(args) + ret = [] + while v = args.shift + ret << v + if v == '--where' + ret << %Q|"#{args.join(' ')}"| + break + end + end + ret.join(' ') end end end end