dohmysql 0.2.21 → 0.2.22
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/lib/doh/mysql/cache_connector.rb +1 -1
 - data/lib/doh/mysql/handle.rb +8 -3
 - data/test/connector_instance.dt.rb +1 -1
 - data/test/handle.dt.rb +10 -1
 - metadata +2 -2
 
| 
         @@ -27,7 +27,7 @@ class CacheConnector 
     | 
|
| 
       27 
27 
     | 
    
         
             
            private
         
     | 
| 
       28 
28 
     | 
    
         
             
              def close_handle(msg)
         
     | 
| 
       29 
29 
     | 
    
         
             
                return unless @handle
         
     | 
| 
       30 
     | 
    
         
            -
                 
     | 
| 
      
 30 
     | 
    
         
            +
                DohDb.logger.call('debug', "closing previous database connection - #{msg}")
         
     | 
| 
       31 
31 
     | 
    
         
             
                @handle.close
         
     | 
| 
       32 
32 
     | 
    
         
             
                @handle = nil
         
     | 
| 
       33 
33 
     | 
    
         
             
              end
         
     | 
    
        data/lib/doh/mysql/handle.rb
    CHANGED
    
    | 
         @@ -18,6 +18,7 @@ class Handle 
     | 
|
| 
       18 
18 
     | 
    
         
             
                @config = config
         
     | 
| 
       19 
19 
     | 
    
         
             
                @testing_rollback = false
         
     | 
| 
       20 
20 
     | 
    
         
             
                log_config = @config.dup
         
     | 
| 
      
 21 
     | 
    
         
            +
                @config[:reconnect] = true if !@config.keys.include?(:reconnect)
         
     | 
| 
       21 
22 
     | 
    
         
             
                log_config.delete(:password)
         
     | 
| 
       22 
23 
     | 
    
         
             
                DohDb.logger.call('connection', "creating connection with config: #{log_config}")
         
     | 
| 
       23 
24 
     | 
    
         
             
                @mysqlh = Mysql2::Client.new(@config)
         
     | 
| 
         @@ -26,9 +27,12 @@ class Handle 
     | 
|
| 
       26 
27 
     | 
    
         | 
| 
       27 
28 
     | 
    
         
             
              def close
         
     | 
| 
       28 
29 
     | 
    
         
             
                unless closed?
         
     | 
| 
       29 
     | 
    
         
            -
                   
     | 
| 
       30 
     | 
    
         
            -
             
     | 
| 
       31 
     | 
    
         
            -
             
     | 
| 
      
 30 
     | 
    
         
            +
                  begin
         
     | 
| 
      
 31 
     | 
    
         
            +
                    DohDb.logger.call('connection', "closing connection: id #{@mysqlh.thread_id}")
         
     | 
| 
      
 32 
     | 
    
         
            +
                    @mysqlh.close
         
     | 
| 
      
 33 
     | 
    
         
            +
                  ensure
         
     | 
| 
      
 34 
     | 
    
         
            +
                    @mysqlh = nil
         
     | 
| 
      
 35 
     | 
    
         
            +
                  end
         
     | 
| 
       32 
36 
     | 
    
         
             
                end
         
     | 
| 
       33 
37 
     | 
    
         
             
              end
         
     | 
| 
       34 
38 
     | 
    
         | 
| 
         @@ -182,6 +186,7 @@ private 
     | 
|
| 
       182 
186 
     | 
    
         
             
                @mysqlh.query(sqlstr)
         
     | 
| 
       183 
187 
     | 
    
         
             
              rescue Exception => excpt
         
     | 
| 
       184 
188 
     | 
    
         
             
                DohDb.logger.call('error', "caught exception #{excpt.message} during query: #{sqlstr}")
         
     | 
| 
      
 189 
     | 
    
         
            +
                close
         
     | 
| 
       185 
190 
     | 
    
         
             
                raise
         
     | 
| 
       186 
191 
     | 
    
         
             
              end
         
     | 
| 
       187 
192 
     | 
    
         | 
| 
         @@ -17,7 +17,6 @@ class Test_ConnectorInstance < DohTest::TestGroup 
     | 
|
| 
       17 
17 
     | 
    
         
             
                assert_equal(nil, Doh.db.select_optional_field("SELECT money FROM #{tbl} WHERE id = 7"))
         
     | 
| 
       18 
18 
     | 
    
         
             
                assert_raises(UnexpectedQueryResult) {Doh.db.select_field("SELECT money FROM #{tbl} WHERE id = 7")}
         
     | 
| 
       19 
19 
     | 
    
         
             
                assert_equal(1, Doh.db.update_row("UPDATE #{tbl} SET money = 10.95 WHERE id = 1"))
         
     | 
| 
       20 
     | 
    
         
            -
                assert_raises(Mysql2::Error){Doh.db.query("some invalid sql here")}
         
     | 
| 
       21 
20 
     | 
    
         
             
                # TODO: re-enable
         
     | 
| 
       22 
21 
     | 
    
         
             
                # assert(DohTest::pop_error)
         
     | 
| 
       23 
22 
     | 
    
         
             
                assert_raises(UnexpectedQueryResult) {Doh.db.update_row("UPDATE #{tbl} SET money = 10.95 WHERE id = 7")}
         
     | 
| 
         @@ -27,6 +26,7 @@ class Test_ConnectorInstance < DohTest::TestGroup 
     | 
|
| 
       27 
26 
     | 
    
         
             
                assert_equal(1, onerow['id'])
         
     | 
| 
       28 
27 
     | 
    
         
             
                rows = Doh.db.select("SELECT * FROM #{tbl}")
         
     | 
| 
       29 
28 
     | 
    
         
             
                rows.each {|row| assert(row['id'] != 0)}
         
     | 
| 
      
 29 
     | 
    
         
            +
                assert_raises(Mysql2::Error){Doh.db.query("some invalid sql here")}
         
     | 
| 
       30 
30 
     | 
    
         
             
              end
         
     | 
| 
       31 
31 
     | 
    
         
             
            end
         
     | 
| 
       32 
32 
     | 
    
         | 
    
        data/test/handle.dt.rb
    CHANGED
    
    | 
         @@ -53,8 +53,17 @@ class Test_Handle < DohTest::TestGroup 
     | 
|
| 
       53 
53 
     | 
    
         
             
                dbh.query("CREATE TEMPORARY TABLE #{tbl} (value INT KEY)")
         
     | 
| 
       54 
54 
     | 
    
         
             
                hash1 = {'value' => 1}
         
     | 
| 
       55 
55 
     | 
    
         
             
                assert_equal(0, dbh.insert_hash(hash1, tbl))
         
     | 
| 
       56 
     | 
    
         
            -
                assert_raises(Mysql2::Error) { dbh.insert_hash(hash1, tbl) }
         
     | 
| 
       57 
56 
     | 
    
         
             
                assert_equal(0, dbh.insert_ignore_hash(hash1, tbl))
         
     | 
| 
      
 57 
     | 
    
         
            +
                assert_raises(Mysql2::Error) { dbh.insert_hash(hash1, tbl) }
         
     | 
| 
      
 58 
     | 
    
         
            +
              end
         
     | 
| 
      
 59 
     | 
    
         
            +
             
     | 
| 
      
 60 
     | 
    
         
            +
              def test_bad_handle_reconnect
         
     | 
| 
      
 61 
     | 
    
         
            +
                dbh = get_dbh
         
     | 
| 
      
 62 
     | 
    
         
            +
                begin
         
     | 
| 
      
 63 
     | 
    
         
            +
                  Timeout.timeout(0.001) { Doh.db.select_field("SELECT SLEEP(1), 0 FROM mysql.user GROUP BY 2") }
         
     | 
| 
      
 64 
     | 
    
         
            +
                rescue => _
         
     | 
| 
      
 65 
     | 
    
         
            +
                end
         
     | 
| 
      
 66 
     | 
    
         
            +
                assert_equal(3, Doh.db.select_field("SELECT 3 FROM mysql.user GROUP BY 1"))
         
     | 
| 
       58 
67 
     | 
    
         
             
              end
         
     | 
| 
       59 
68 
     | 
    
         
             
            end
         
     | 
| 
       60 
69 
     | 
    
         | 
    
        metadata
    CHANGED
    
    | 
         @@ -1,7 +1,7 @@ 
     | 
|
| 
       1 
1 
     | 
    
         
             
            --- !ruby/object:Gem::Specification
         
     | 
| 
       2 
2 
     | 
    
         
             
            name: dohmysql
         
     | 
| 
       3 
3 
     | 
    
         
             
            version: !ruby/object:Gem::Version
         
     | 
| 
       4 
     | 
    
         
            -
              version: 0.2. 
     | 
| 
      
 4 
     | 
    
         
            +
              version: 0.2.22
         
     | 
| 
       5 
5 
     | 
    
         
             
              prerelease: 
         
     | 
| 
       6 
6 
     | 
    
         
             
            platform: ruby
         
     | 
| 
       7 
7 
     | 
    
         
             
            authors:
         
     | 
| 
         @@ -10,7 +10,7 @@ authors: 
     | 
|
| 
       10 
10 
     | 
    
         
             
            autorequire: 
         
     | 
| 
       11 
11 
     | 
    
         
             
            bindir: bin
         
     | 
| 
       12 
12 
     | 
    
         
             
            cert_chain: []
         
     | 
| 
       13 
     | 
    
         
            -
            date: 2013-05- 
     | 
| 
      
 13 
     | 
    
         
            +
            date: 2013-05-21 00:00:00.000000000 Z
         
     | 
| 
       14 
14 
     | 
    
         
             
            dependencies:
         
     | 
| 
       15 
15 
     | 
    
         
             
            - !ruby/object:Gem::Dependency
         
     | 
| 
       16 
16 
     | 
    
         
             
              name: dohroot
         
     |