fluent-plugin-mysql-replicator 0.4.1 → 0.4.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/.travis.yml +1 -1
 - data/fluent-plugin-mysql-replicator.gemspec +1 -1
 - data/lib/fluent/plugin/in_mysql_replicator.rb +6 -3
 - data/lib/fluent/plugin/in_mysql_replicator_multi.rb +2 -1
 - data/test/plugin/test_in_mysql_replicator.rb +0 -1
 - data/test/plugin/test_in_mysql_replicator_multi.rb +0 -1
 - metadata +2 -2
 
    
        data/.travis.yml
    CHANGED
    
    
| 
         @@ -1,7 +1,7 @@ 
     | 
|
| 
       1 
1 
     | 
    
         
             
            # -*- encoding: utf-8 -*-
         
     | 
| 
       2 
2 
     | 
    
         
             
            Gem::Specification.new do |s|
         
     | 
| 
       3 
3 
     | 
    
         
             
              s.name        = "fluent-plugin-mysql-replicator"
         
     | 
| 
       4 
     | 
    
         
            -
              s.version     = "0.4. 
     | 
| 
      
 4 
     | 
    
         
            +
              s.version     = "0.4.2"
         
     | 
| 
       5 
5 
     | 
    
         
             
              s.authors     = ["Kentaro Yoshida"]
         
     | 
| 
       6 
6 
     | 
    
         
             
              s.email       = ["y.ken.studio@gmail.com"]
         
     | 
| 
       7 
7 
     | 
    
         
             
              s.homepage    = "https://github.com/y-ken/fluent-plugin-mysql-replicator"
         
     | 
| 
         @@ -59,16 +59,19 @@ module Fluent 
     | 
|
| 
       59 
59 
     | 
    
         
             
                    previous_ids = ids
         
     | 
| 
       60 
60 
     | 
    
         
             
                    current_ids = Array.new
         
     | 
| 
       61 
61 
     | 
    
         
             
                    prepared_con = get_connection()
         
     | 
| 
       62 
     | 
    
         
            -
                     
     | 
| 
       63 
     | 
    
         
            -
                       
     | 
| 
      
 62 
     | 
    
         
            +
                    if !@prepared_query.nil?
         
     | 
| 
      
 63 
     | 
    
         
            +
                      @prepared_query.split(/;/).each do |query|
         
     | 
| 
      
 64 
     | 
    
         
            +
                        prepared_con.query(query)
         
     | 
| 
      
 65 
     | 
    
         
            +
                      end
         
     | 
| 
       64 
66 
     | 
    
         
             
                    end
         
     | 
| 
       65 
67 
     | 
    
         
             
                    query(@query).each do |row|
         
     | 
| 
       66 
68 
     | 
    
         
             
                      current_ids << row[@primary_key]
         
     | 
| 
       67 
69 
     | 
    
         
             
                      current_hash = Digest::SHA1.hexdigest(row.flatten.join)
         
     | 
| 
       68 
     | 
    
         
            -
                      row.each {|k, v| row[k] = v.to_s if v.is_a?(Time) || v.is_a?(Date)}
         
     | 
| 
      
 70 
     | 
    
         
            +
                      row.each {|k, v| row[k] = v.to_s if v.is_a?(Time) || v.is_a?(Date) || v.is_a?(BigDecimal)}
         
     | 
| 
       69 
71 
     | 
    
         
             
                      row.select {|k, v| v.to_s.strip.match(/^SELECT/i) }.each do |k, v|
         
     | 
| 
       70 
72 
     | 
    
         
             
                        row[k] = [] unless row[k].is_a?(Array)
         
     | 
| 
       71 
73 
     | 
    
         
             
                        prepared_con.query(v.gsub(/\$\{([^\}]+)\}/, row[$1].to_s)).each do |nest_row|
         
     | 
| 
      
 74 
     | 
    
         
            +
                          nest_row.each {|k, v| nest_row[k] = v.to_s if v.is_a?(Time) || v.is_a?(Date) || v.is_a?(BigDecimal)}
         
     | 
| 
       72 
75 
     | 
    
         
             
                          row[k] << nest_row
         
     | 
| 
       73 
76 
     | 
    
         
             
                        end
         
     | 
| 
       74 
77 
     | 
    
         
             
                      end
         
     | 
| 
         @@ -83,10 +83,11 @@ module Fluent 
     | 
|
| 
       83 
83 
     | 
    
         
             
                      end
         
     | 
| 
       84 
84 
     | 
    
         
             
                      db = get_origin_connection(config)
         
     | 
| 
       85 
85 
     | 
    
         
             
                      db.query(config['query']).each do |row|
         
     | 
| 
       86 
     | 
    
         
            -
                        row.each {|k, v| row[k] = v.to_s if v.is_a?(Time) || v.is_a?(Date)}
         
     | 
| 
      
 86 
     | 
    
         
            +
                        row.each {|k, v| row[k] = v.to_s if v.is_a?(Time) || v.is_a?(Date) || v.is_a?(BigDecimal)}
         
     | 
| 
       87 
87 
     | 
    
         
             
                        row.select {|k, v| v.to_s.strip.match(/^SELECT/i) }.each do |k, v|
         
     | 
| 
       88 
88 
     | 
    
         
             
                          row[k] = [] unless row[k].is_a?(Array)
         
     | 
| 
       89 
89 
     | 
    
         
             
                          nest_db.query(v.gsub(/\$\{([^\}]+)\}/) {|matched| row[$1].to_s}).each do |nest_row|
         
     | 
| 
      
 90 
     | 
    
         
            +
                            nest_row.each {|k, v| nest_row[k] = v.to_s if v.is_a?(Time) || v.is_a?(Date) || v.is_a?(BigDecimal)}
         
     | 
| 
       90 
91 
     | 
    
         
             
                            row[k] << nest_row
         
     | 
| 
       91 
92 
     | 
    
         
             
                          end
         
     | 
| 
       92 
93 
     | 
    
         
             
                        end
         
     | 
| 
         @@ -30,7 +30,6 @@ class MysqlReplicatorInputTest < Test::Unit::TestCase 
     | 
|
| 
       30 
30 
     | 
    
         
             
                  query           SELECT id, text from search_text
         
     | 
| 
       31 
31 
     | 
    
         
             
                  enable_delete   no
         
     | 
| 
       32 
32 
     | 
    
         
             
                ]
         
     | 
| 
       33 
     | 
    
         
            -
                d.instance.inspect
         
     | 
| 
       34 
33 
     | 
    
         
             
                assert_equal 'localhost', d.instance.host
         
     | 
| 
       35 
34 
     | 
    
         
             
                assert_equal 3306, d.instance.port
         
     | 
| 
       36 
35 
     | 
    
         
             
                assert_equal 30, d.instance.interval
         
     | 
| 
         @@ -22,7 +22,6 @@ class MysqlReplicatorMultiInputTest < Test::Unit::TestCase 
     | 
|
| 
       22 
22 
     | 
    
         
             
                  d = create_driver('')
         
     | 
| 
       23 
23 
     | 
    
         
             
                }
         
     | 
| 
       24 
24 
     | 
    
         
             
                d = create_driver(CONFIG)
         
     | 
| 
       25 
     | 
    
         
            -
                d.instance.inspect
         
     | 
| 
       26 
25 
     | 
    
         
             
                assert_equal 'localhost', d.instance.manager_host
         
     | 
| 
       27 
26 
     | 
    
         
             
                assert_equal 3306, d.instance.manager_port
         
     | 
| 
       28 
27 
     | 
    
         
             
                assert_equal 'replicator_manager', d.instance.manager_database
         
     | 
    
        metadata
    CHANGED
    
    | 
         @@ -1,7 +1,7 @@ 
     | 
|
| 
       1 
1 
     | 
    
         
             
            --- !ruby/object:Gem::Specification
         
     | 
| 
       2 
2 
     | 
    
         
             
            name: fluent-plugin-mysql-replicator
         
     | 
| 
       3 
3 
     | 
    
         
             
            version: !ruby/object:Gem::Version
         
     | 
| 
       4 
     | 
    
         
            -
              version: 0.4. 
     | 
| 
      
 4 
     | 
    
         
            +
              version: 0.4.2
         
     | 
| 
       5 
5 
     | 
    
         
             
              prerelease: 
         
     | 
| 
       6 
6 
     | 
    
         
             
            platform: ruby
         
     | 
| 
       7 
7 
     | 
    
         
             
            authors:
         
     | 
| 
         @@ -9,7 +9,7 @@ authors: 
     | 
|
| 
       9 
9 
     | 
    
         
             
            autorequire: 
         
     | 
| 
       10 
10 
     | 
    
         
             
            bindir: bin
         
     | 
| 
       11 
11 
     | 
    
         
             
            cert_chain: []
         
     | 
| 
       12 
     | 
    
         
            -
            date: 2014- 
     | 
| 
      
 12 
     | 
    
         
            +
            date: 2014-07-30 00:00:00.000000000 Z
         
     | 
| 
       13 
13 
     | 
    
         
             
            dependencies:
         
     | 
| 
       14 
14 
     | 
    
         
             
            - !ruby/object:Gem::Dependency
         
     | 
| 
       15 
15 
     | 
    
         
             
              name: rake
         
     |