schema_plus 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.
- checksums.yaml +4 -4
- data/README.md +9 -0
- data/gemfiles/rails-edge/Gemfile.base +1 -1
- data/lib/schema_plus/active_record/connection_adapters/postgresql_adapter.rb +7 -2
- data/lib/schema_plus/active_record/schema_dumper.rb +4 -5
- data/lib/schema_plus/version.rb +1 -1
- data/schema_plus.gemspec +1 -0
- data/spec/schema_dumper_spec.rb +7 -0
- metadata +16 -2
    
        checksums.yaml
    CHANGED
    
    | @@ -1,7 +1,7 @@ | |
| 1 1 | 
             
            ---
         | 
| 2 2 | 
             
            SHA1:
         | 
| 3 | 
            -
              metadata.gz:  | 
| 4 | 
            -
              data.tar.gz:  | 
| 3 | 
            +
              metadata.gz: fb0e9e9c0ae722f3745bf153ca27e10feba32557
         | 
| 4 | 
            +
              data.tar.gz: 475c3532ec3953c3b34c68357dec44b69b5554e5
         | 
| 5 5 | 
             
            SHA512:
         | 
| 6 | 
            -
              metadata.gz:  | 
| 7 | 
            -
              data.tar.gz:  | 
| 6 | 
            +
              metadata.gz: b0e183c3f7af709ebe5b8fb73f9278a3c5a9cf1a9d31ae39934d12ef727df309772edc43dfbf5e06b4202a5216f19307d4438da67c883e6a974ec2c581b0692d
         | 
| 7 | 
            +
              data.tar.gz: 5fe1d3eaacef6220fa894d3b491fddeac460856567e32972a63d95373e590e9a0ddc58111bd6ee198dd3baa1e520ee834cedc81dc798f1e5f3bd19735c904dfa
         | 
    
        data/README.md
    CHANGED
    
    | @@ -300,6 +300,11 @@ of foreign key constraints, you can re-enable it: | |
| 300 300 |  | 
| 301 301 | 
             
            * *nothing currently waiting to be released*
         | 
| 302 302 |  | 
| 303 | 
            +
            ### 1.3.3
         | 
| 304 | 
            +
             | 
| 305 | 
            +
            * Bug fix, dump unique index with expression (Issue #142)
         | 
| 306 | 
            +
             | 
| 307 | 
            +
             | 
| 303 308 | 
             
            ### 1.3.2
         | 
| 304 309 |  | 
| 305 310 | 
             
            * Bug fix, remove_index with if_exists but no name
         | 
| @@ -409,3 +414,7 @@ of foreign key constraints, you can re-enable it: | |
| 409 414 | 
             
                contributors](https://github.com/lomba/schema_plus/graphs/contributors)
         | 
| 410 415 | 
             
                since then
         | 
| 411 416 |  | 
| 417 | 
            +
             | 
| 418 | 
            +
             | 
| 419 | 
            +
            [](https://bitdeli.com/free "Bitdeli Badge")
         | 
| 420 | 
            +
             | 
| @@ -215,7 +215,10 @@ module SchemaPlus | |
| 215 215 | 
             
                    # Prepass to replace each ActiveRecord::DB_DEFAULT with a literal
         | 
| 216 216 | 
             
                    # DEFAULT in the sql string.  (The underlying pg gem provides no
         | 
| 217 217 | 
             
                    # way to bind a value that will replace $n with DEFAULT)
         | 
| 218 | 
            -
                    def exec_cache_with_schema_plus(sql,  | 
| 218 | 
            +
                    def exec_cache_with_schema_plus(sql, *args)
         | 
| 219 | 
            +
                      name_passed = (2 == args.size)
         | 
| 220 | 
            +
                      binds, name = args.reverse
         | 
| 221 | 
            +
             | 
| 219 222 | 
             
                      if binds.any?{ |col, val| val.equal? ::ActiveRecord::DB_DEFAULT}
         | 
| 220 223 | 
             
                        j = 0
         | 
| 221 224 | 
             
                        binds.each_with_index do |(col, val), i|
         | 
| @@ -228,7 +231,9 @@ module SchemaPlus | |
| 228 231 | 
             
                        end
         | 
| 229 232 | 
             
                        binds = binds.reject{|col, val| val.equal? ::ActiveRecord::DB_DEFAULT}
         | 
| 230 233 | 
             
                      end
         | 
| 231 | 
            -
             | 
| 234 | 
            +
             | 
| 235 | 
            +
                      args = name_passed ? [name, binds] : [binds]
         | 
| 236 | 
            +
                      exec_cache_without_schema_plus(sql, *args)
         | 
| 232 237 | 
             
                    end
         | 
| 233 238 |  | 
| 234 239 | 
             
                    def foreign_keys(table_name, name = nil) #:nodoc:
         | 
| @@ -118,18 +118,17 @@ module SchemaPlus | |
| 118 118 | 
             
                  def dump_indexes(table) #:nodoc:
         | 
| 119 119 | 
             
                    @connection.indexes(table).collect{ |index|
         | 
| 120 120 | 
             
                      dump = "    t.index"
         | 
| 121 | 
            +
                      dump << " #{index.columns.inspect}," unless index.columns.blank?
         | 
| 122 | 
            +
                      dump << " :name => #{index.name.inspect}"
         | 
| 123 | 
            +
                      dump << ", :unique => true" if index.unique
         | 
| 124 | 
            +
                      dump << ", :kind => \"#{index.kind}\"" unless index.kind.blank?
         | 
| 121 125 | 
             
                      unless index.columns.blank? 
         | 
| 122 | 
            -
                        dump << " #{index.columns.inspect}, :name => #{index.name.inspect}"
         | 
| 123 | 
            -
                        dump << ", :unique => true" if index.unique
         | 
| 124 | 
            -
                        dump << ", :kind => \"#{index.kind}\"" unless index.kind.blank?
         | 
| 125 126 | 
             
                        dump << ", :case_sensitive => false" unless index.case_sensitive?
         | 
| 126 127 | 
             
                        dump << ", :conditions => #{index.conditions.inspect}" unless index.conditions.blank?
         | 
| 127 128 | 
             
                        index_lengths = index.lengths.compact if index.lengths.is_a?(Array)
         | 
| 128 129 | 
             
                        dump << ", :length => #{Hash[*index.columns.zip(index.lengths).flatten].inspect}" if index_lengths.present?
         | 
| 129 130 | 
             
                        dump << ", :order => {" + index.orders.map{|column, val| "#{column.inspect} => #{val.inspect}"}.join(", ") + "}" unless index.orders.blank?
         | 
| 130 131 | 
             
                      else
         | 
| 131 | 
            -
                        dump << " :name => #{index.name.inspect}"
         | 
| 132 | 
            -
                        dump << ", :kind => \"#{index.kind}\"" unless index.kind.blank?
         | 
| 133 132 | 
             
                        dump << ", :expression => #{index.expression.inspect}"
         | 
| 134 133 | 
             
                      end
         | 
| 135 134 | 
             
                      dump << "\n"
         | 
    
        data/lib/schema_plus/version.rb
    CHANGED
    
    
    
        data/schema_plus.gemspec
    CHANGED
    
    | @@ -25,6 +25,7 @@ Gem::Specification.new do |s| | |
| 25 25 |  | 
| 26 26 | 
             
              s.add_development_dependency("rake")
         | 
| 27 27 | 
             
              s.add_development_dependency("rspec")
         | 
| 28 | 
            +
              s.add_development_dependency("rdoc")
         | 
| 28 29 | 
             
              s.add_development_dependency("simplecov")
         | 
| 29 30 | 
             
              s.add_development_dependency("simplecov-gem-adapter")
         | 
| 30 31 | 
             
            end
         | 
    
        data/spec/schema_dumper_spec.rb
    CHANGED
    
    | @@ -221,6 +221,13 @@ describe "Schema dump" do | |
| 221 221 | 
             
                  end
         | 
| 222 222 | 
             
                end
         | 
| 223 223 |  | 
| 224 | 
            +
                it "should dump unique: true with expression (Issue #142)" do
         | 
| 225 | 
            +
                  with_index Post, :name => "posts_user_body_index", :unique => true, :expression => "BTRIM(LOWER(body))" do
         | 
| 226 | 
            +
                    dump_posts.should match(%r{#{to_regexp(%q{t.index :name => "posts_user_body_index", :unique => true, :expression => "btrim(lower(body))"})}$})
         | 
| 227 | 
            +
                  end
         | 
| 228 | 
            +
                end
         | 
| 229 | 
            +
             | 
| 230 | 
            +
             | 
| 224 231 | 
             
                it "should not define :case_sensitive => false with non-trivial expression" do
         | 
| 225 232 | 
             
                  with_index Post, :name => "posts_user_body_index", :expression => "BTRIM(LOWER(body))" do
         | 
| 226 233 | 
             
                    dump_posts.should match(%r{#{to_regexp(%q{t.index :name => "posts_user_body_index", :expression => "btrim(lower(body))"})}$})
         | 
    
        metadata
    CHANGED
    
    | @@ -1,7 +1,7 @@ | |
| 1 1 | 
             
            --- !ruby/object:Gem::Specification
         | 
| 2 2 | 
             
            name: schema_plus
         | 
| 3 3 | 
             
            version: !ruby/object:Gem::Version
         | 
| 4 | 
            -
              version: 1.3. | 
| 4 | 
            +
              version: 1.3.3
         | 
| 5 5 | 
             
            platform: ruby
         | 
| 6 6 | 
             
            authors:
         | 
| 7 7 | 
             
            - Ronen Barzel
         | 
| @@ -9,7 +9,7 @@ authors: | |
| 9 9 | 
             
            autorequire: 
         | 
| 10 10 | 
             
            bindir: bin
         | 
| 11 11 | 
             
            cert_chain: []
         | 
| 12 | 
            -
            date:  | 
| 12 | 
            +
            date: 2014-02-04 00:00:00.000000000 Z
         | 
| 13 13 | 
             
            dependencies:
         | 
| 14 14 | 
             
            - !ruby/object:Gem::Dependency
         | 
| 15 15 | 
             
              name: rails
         | 
| @@ -67,6 +67,20 @@ dependencies: | |
| 67 67 | 
             
                - - '>='
         | 
| 68 68 | 
             
                  - !ruby/object:Gem::Version
         | 
| 69 69 | 
             
                    version: '0'
         | 
| 70 | 
            +
            - !ruby/object:Gem::Dependency
         | 
| 71 | 
            +
              name: rdoc
         | 
| 72 | 
            +
              requirement: !ruby/object:Gem::Requirement
         | 
| 73 | 
            +
                requirements:
         | 
| 74 | 
            +
                - - '>='
         | 
| 75 | 
            +
                  - !ruby/object:Gem::Version
         | 
| 76 | 
            +
                    version: '0'
         | 
| 77 | 
            +
              type: :development
         | 
| 78 | 
            +
              prerelease: false
         | 
| 79 | 
            +
              version_requirements: !ruby/object:Gem::Requirement
         | 
| 80 | 
            +
                requirements:
         | 
| 81 | 
            +
                - - '>='
         | 
| 82 | 
            +
                  - !ruby/object:Gem::Version
         | 
| 83 | 
            +
                    version: '0'
         | 
| 70 84 | 
             
            - !ruby/object:Gem::Dependency
         | 
| 71 85 | 
             
              name: simplecov
         | 
| 72 86 | 
             
              requirement: !ruby/object:Gem::Requirement
         |