db_leftovers 1.3.2 → 1.3.3
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.
| @@ -15,12 +15,13 @@ module DBLeftovers | |
| 15 15 | 
             
                              i.relname AS index_name,
         | 
| 16 16 | 
             
                              ix.indisunique AS is_unique,
         | 
| 17 17 | 
             
                              array_to_string(ix.indkey, ',') AS column_numbers,
         | 
| 18 | 
            -
                               | 
| 18 | 
            +
                              am.amname AS index_type,
         | 
| 19 19 | 
             
                              pg_get_expr(ix.indpred, ix.indrelid) AS where_clause
         | 
| 20 20 | 
             
                      FROM    pg_class t,
         | 
| 21 21 | 
             
                              pg_class i,
         | 
| 22 22 | 
             
                              pg_index ix,
         | 
| 23 | 
            -
                              pg_namespace n
         | 
| 23 | 
            +
                              pg_namespace n,
         | 
| 24 | 
            +
                              pg_am am
         | 
| 24 25 | 
             
                      WHERE   t.oid = ix.indrelid
         | 
| 25 26 | 
             
                      AND     n.oid = t.relnamespace
         | 
| 26 27 | 
             
                      AND     i.oid = ix.indexrelid
         | 
| @@ -28,19 +29,19 @@ module DBLeftovers | |
| 28 29 | 
             
                      AND     n.nspname NOT IN ('pg_catalog', 'pg_toast')
         | 
| 29 30 | 
             
                      AND     pg_catalog.pg_table_is_visible(t.oid)
         | 
| 30 31 | 
             
                      AND     NOT ix.indisprimary
         | 
| 32 | 
            +
                      AND     i.relam = am.oid
         | 
| 31 33 | 
             
                      GROUP BY  t.relname,
         | 
| 32 34 | 
             
                                i.relname,
         | 
| 33 35 | 
             
                                ix.indisunique,
         | 
| 34 36 | 
             
                                ix.indexrelid,
         | 
| 35 37 | 
             
                                ix.indrelid,
         | 
| 36 38 | 
             
                                ix.indkey,
         | 
| 37 | 
            -
                                 | 
| 39 | 
            +
                                am.amname,
         | 
| 38 40 | 
             
                                ix.indpred
         | 
| 39 41 | 
             
                      ORDER BY t.relname, i.relname
         | 
| 40 42 | 
             
                  EOQ
         | 
| 41 | 
            -
                  @conn.select_rows(sql).each do |indexrelid, indrelid, table_name, index_name, is_unique, column_numbers,  | 
| 43 | 
            +
                  @conn.select_rows(sql).each do |indexrelid, indrelid, table_name, index_name, is_unique, column_numbers, index_method, where_clause|
         | 
| 42 44 | 
             
                    where_clause = remove_outer_parens(where_clause) if where_clause
         | 
| 43 | 
            -
                    index_method = index_method_for_op(op_numbers.split(",").first)
         | 
| 44 45 | 
             
                    index_method = nil if index_method == 'btree'
         | 
| 45 46 | 
             
                    ret[index_name] = Index.new(
         | 
| 46 47 | 
             
                      table_name,
         | 
| @@ -138,15 +139,6 @@ module DBLeftovers | |
| 138 139 | 
             
                  end
         | 
| 139 140 | 
             
                end
         | 
| 140 141 |  | 
| 141 | 
            -
                def index_method_for_op(op_id)
         | 
| 142 | 
            -
                  @conn.select_value(<<-EOQ)
         | 
| 143 | 
            -
                      SELECT  am.amname
         | 
| 144 | 
            -
                      FROM    pg_opclass op, pg_am am
         | 
| 145 | 
            -
                      WHERE   op.oid = #{op_id}
         | 
| 146 | 
            -
                      AND     op.opcmethod = am.oid
         | 
| 147 | 
            -
                  EOQ
         | 
| 148 | 
            -
                end
         | 
| 149 | 
            -
             | 
| 150 142 | 
             
                def remove_outer_parens(str)
         | 
| 151 143 | 
             
                  str ? str.gsub(/^\((.*)\)$/, '\1') : nil
         | 
| 152 144 | 
             
                end
         | 
    
        data/lib/db_leftovers/version.rb
    CHANGED
    
    
    
        metadata
    CHANGED
    
    | @@ -1,7 +1,7 @@ | |
| 1 1 | 
             
            --- !ruby/object:Gem::Specification
         | 
| 2 2 | 
             
            name: db_leftovers
         | 
| 3 3 | 
             
            version: !ruby/object:Gem::Version
         | 
| 4 | 
            -
              version: 1.3. | 
| 4 | 
            +
              version: 1.3.3
         | 
| 5 5 | 
             
              prerelease: 
         | 
| 6 6 | 
             
            platform: ruby
         | 
| 7 7 | 
             
            authors:
         | 
| @@ -111,7 +111,7 @@ required_ruby_version: !ruby/object:Gem::Requirement | |
| 111 111 | 
             
                  version: '0'
         | 
| 112 112 | 
             
                  segments:
         | 
| 113 113 | 
             
                  - 0
         | 
| 114 | 
            -
                  hash:  | 
| 114 | 
            +
                  hash: 3023613074233627262
         | 
| 115 115 | 
             
            required_rubygems_version: !ruby/object:Gem::Requirement
         | 
| 116 116 | 
             
              none: false
         | 
| 117 117 | 
             
              requirements:
         |