sessionm-cassandra_object 4.0.5 → 4.0.6
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/lib/cassandra_object/adapters/cassandra_driver.rb +10 -4
- data/lib/cassandra_object/persistence.rb +3 -7
- data/sessionm-cassandra_object.gemspec +1 -1
- data/spec/cassandra_object/adapters/cassandra_driver_spec.rb +10 -0
- data/spec/cassandra_object/persistence_spec.rb +13 -0
- metadata +5 -1
    
        checksums.yaml
    CHANGED
    
    | @@ -1,7 +1,7 @@ | |
| 1 1 | 
             
            ---
         | 
| 2 2 | 
             
            SHA1:
         | 
| 3 | 
            -
              metadata.gz:  | 
| 4 | 
            -
              data.tar.gz:  | 
| 3 | 
            +
              metadata.gz: 539bceeb4486ffdd621cb72f76d716f870f4e18a
         | 
| 4 | 
            +
              data.tar.gz: 45e22b538f31d1c1657be029fac182f8e16b618f
         | 
| 5 5 | 
             
            SHA512:
         | 
| 6 | 
            -
              metadata.gz:  | 
| 7 | 
            -
              data.tar.gz:  | 
| 6 | 
            +
              metadata.gz: 85e074b00d7e502eb1b7e20d42dd2b6b47a4cd2de6e5dc324612636f3db5c9f130d17ca4d9f3d7aa3ff667efc16fe817ef819158a449e7c1b923a71e43674bff
         | 
| 7 | 
            +
              data.tar.gz: e2d391a541f081c3e262ecd61eeeeff0144c7cdce355873795800578818559eee845170baf132d54549252358c1ac6114a656413d495d8d68ef5b3fa28b325c9
         | 
| @@ -108,13 +108,15 @@ module CassandraObject | |
| 108 108 | 
             
                      end
         | 
| 109 109 | 
             
                    end
         | 
| 110 110 |  | 
| 111 | 
            -
                    def add(column_family, key, by,  | 
| 111 | 
            +
                    def add(column_family, key, by, fields, opts=nil)
         | 
| 112 112 | 
             
                      async = opts.try(:[], :async)
         | 
| 113 | 
            +
                      fields = [fields] unless fields.is_a?(Array)
         | 
| 113 114 | 
             
                      key = "textAsBlob('#{key}')"
         | 
| 114 115 |  | 
| 115 | 
            -
                       | 
| 116 | 
            -
             | 
| 117 | 
            -
             | 
| 116 | 
            +
                      fields.each do |field|
         | 
| 117 | 
            +
                        query = "UPDATE \"#{column_family}\" SET #{VALUE_FIELD} = #{VALUE_FIELD} + #{by} WHERE #{KEY_FIELD} = #{key} AND #{NAME_FIELD} = '#{field}';"
         | 
| 118 | 
            +
                        async ? self.execute_async(query, execute_options(opts)) : self.execute(query, execute_options(opts))
         | 
| 119 | 
            +
                      end
         | 
| 118 120 | 
             
                    end
         | 
| 119 121 |  | 
| 120 122 | 
             
                    def remove(column_family, key, *args)
         | 
| @@ -168,6 +170,10 @@ module CassandraObject | |
| 168 170 | 
             
                    def schema_cache
         | 
| 169 171 | 
             
                      @schema_cache ||= SchemaCache.new(self)
         | 
| 170 172 | 
             
                    end
         | 
| 173 | 
            +
             | 
| 174 | 
            +
                    def column_families
         | 
| 175 | 
            +
                      @column_families ||= self.cluster.keyspace(session.keyspace).tables.inject({}) { |hsh, table| hsh[table.name] = table; hsh }
         | 
| 176 | 
            +
                    end
         | 
| 171 177 | 
             
                  end
         | 
| 172 178 | 
             
                end
         | 
| 173 179 | 
             
              end
         | 
| @@ -3,14 +3,10 @@ module CassandraObject | |
| 3 3 | 
             
                extend ActiveSupport::Concern
         | 
| 4 4 |  | 
| 5 5 | 
             
                module ClassMethods
         | 
| 6 | 
            -
                  def add(key, value, * | 
| 7 | 
            -
                    column_family, column, sub_column, options = CassandraObject::Base.with_connection(key, :write) { connection.extract_and_validate_params(self.column_family, key, columns_and_options, {}) }
         | 
| 8 | 
            -
                    # the options are removed, leaving just columns
         | 
| 9 | 
            -
                    columns = columns_and_options
         | 
| 10 | 
            -
             | 
| 6 | 
            +
                  def add(key, value, *columns)
         | 
| 11 7 | 
             
                    CassandraObject::Base.with_connection(key, :write) do
         | 
| 12 | 
            -
                      ActiveSupport::Notifications.instrument("add.cassandra_object", column_family: column_family, key: key, column:  | 
| 13 | 
            -
                        connection.add(column_family, key, value,  | 
| 8 | 
            +
                      ActiveSupport::Notifications.instrument("add.cassandra_object", column_family: column_family, key: key, column: columns, value: value) do
         | 
| 9 | 
            +
                        connection.add(column_family, key, value, columns, :consistency => thrift_write_consistency)
         | 
| 14 10 | 
             
                      end
         | 
| 15 11 | 
             
                    end
         | 
| 16 12 | 
             
                  end
         | 
| @@ -0,0 +1,10 @@ | |
| 1 | 
            +
            require 'spec_helper'
         | 
| 2 | 
            +
             | 
| 3 | 
            +
            describe CassandraObject::Adapters::CassandraDriver do
         | 
| 4 | 
            +
              context "Client" do
         | 
| 5 | 
            +
                it "should return the column family definition by name" do
         | 
| 6 | 
            +
                  expect(Issue.connection.column_families['Issues'].present?).to be true
         | 
| 7 | 
            +
                  expect(Issue.connection.column_families['Unknowns'].present?).to be false
         | 
| 8 | 
            +
                end
         | 
| 9 | 
            +
              end
         | 
| 10 | 
            +
            end
         | 
| @@ -0,0 +1,13 @@ | |
| 1 | 
            +
            require 'spec_helper'
         | 
| 2 | 
            +
             | 
| 3 | 
            +
            describe CassandraObject::Persistence do
         | 
| 4 | 
            +
              context "add" do
         | 
| 5 | 
            +
                it "should increment the counter" do
         | 
| 6 | 
            +
                  id = SimpleUUID::UUID.new.to_guid
         | 
| 7 | 
            +
                  Counter.add id, 1, 'foo'
         | 
| 8 | 
            +
                  expect(Counter.get_counter(id, 'foo')).to eq 1
         | 
| 9 | 
            +
                  Counter.add id, 1, 'foo'
         | 
| 10 | 
            +
                  expect(Counter.get_counter(id, 'foo')).to eq 2
         | 
| 11 | 
            +
                end
         | 
| 12 | 
            +
              end
         | 
| 13 | 
            +
            end
         | 
    
        metadata
    CHANGED
    
    | @@ -1,7 +1,7 @@ | |
| 1 1 | 
             
            --- !ruby/object:Gem::Specification
         | 
| 2 2 | 
             
            name: sessionm-cassandra_object
         | 
| 3 3 | 
             
            version: !ruby/object:Gem::Version
         | 
| 4 | 
            -
              version: 4.0. | 
| 4 | 
            +
              version: 4.0.6
         | 
| 5 5 | 
             
            platform: ruby
         | 
| 6 6 | 
             
            authors:
         | 
| 7 7 | 
             
            - Michael Koziarski
         | 
| @@ -96,8 +96,10 @@ files: | |
| 96 96 | 
             
            - lib/cassandra_object/validations.rb
         | 
| 97 97 | 
             
            - script/console.rb
         | 
| 98 98 | 
             
            - sessionm-cassandra_object.gemspec
         | 
| 99 | 
            +
            - spec/cassandra_object/adapters/cassandra_driver_spec.rb
         | 
| 99 100 | 
             
            - spec/cassandra_object/associations_spec.rb
         | 
| 100 101 | 
             
            - spec/cassandra_object/base_spec.rb
         | 
| 102 | 
            +
            - spec/cassandra_object/persistence_spec.rb
         | 
| 101 103 | 
             
            - spec/spec_helper.rb
         | 
| 102 104 | 
             
            - spec/support/cassandra.rb
         | 
| 103 105 | 
             
            - spec/support/db/migrate/001_create_test_tables.rb
         | 
| @@ -154,8 +156,10 @@ signing_key: | |
| 154 156 | 
             
            specification_version: 4
         | 
| 155 157 | 
             
            summary: Cassandra ActiveModel
         | 
| 156 158 | 
             
            test_files:
         | 
| 159 | 
            +
            - spec/cassandra_object/adapters/cassandra_driver_spec.rb
         | 
| 157 160 | 
             
            - spec/cassandra_object/associations_spec.rb
         | 
| 158 161 | 
             
            - spec/cassandra_object/base_spec.rb
         | 
| 162 | 
            +
            - spec/cassandra_object/persistence_spec.rb
         | 
| 159 163 | 
             
            - spec/spec_helper.rb
         | 
| 160 164 | 
             
            - spec/support/cassandra.rb
         | 
| 161 165 | 
             
            - spec/support/db/migrate/001_create_test_tables.rb
         |