cequel 1.8.0 → 1.9.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 533e3980f9450dfeafb79127893006ba81fb3b64
4
- data.tar.gz: 534f0031b6098578ae6fa1a12668dcf537cca564
3
+ metadata.gz: 769586127721ed091afdca815dd777b0c2f1c45b
4
+ data.tar.gz: 32ae7dab6f20e1e545e5d1c9ca82ec6a8f49a619
5
5
  SHA512:
6
- metadata.gz: bba81999115ee78bd0980340d331f20794aa7aece07cedce42bcd235c6d0a6cfd2e58a67c7a37ccc157972a59de12a1a03918556871740deaa3f452e05728198
7
- data.tar.gz: 697022e12729db4a4bbeca38f9569d4452d196b003feb59db93d843f80bebbd672ddc2ffc262dfe263238b3f78776e7d59a1ac7ec4e27531aab38ef6f4a53185
6
+ metadata.gz: b83ace65af35841571cb4420e52c2664680d40f64d04e411ab93aca11b9de7ffc0305d921d4c2e6036c09d4958349090e5ced9ff402ffebf6cf5afc2b4130286
7
+ data.tar.gz: fecc7319b72e30ded2ddf98d5760e5da6bb3c289381a682c0f3a7cb1ef7e60f36640acb621d95b1992ae16e53a170e2045dd7180b60550cbdc1d9336d477b0be
data/CHANGELOG.md CHANGED
@@ -1,3 +1,9 @@
1
+ ## 1.9.0
2
+
3
+ * NewRelic instrumentation
4
+ * fix querying tables whose first partition key is a timestamp
5
+
6
+
1
7
  ## 1.8.0
2
8
 
3
9
  * remove false claims of Rubinius support from readme (we would gratefully accept a PR to fix compatibility)
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- cequel (1.8.0)
4
+ cequel (1.9.0)
5
5
  activemodel (~> 4.0)
6
6
  cassandra-driver (~> 2.0)
7
7
 
@@ -1,6 +1,6 @@
1
1
  # -*- encoding : utf-8 -*-
2
2
  begin
3
- require 'new_relic/agent/method_tracer'
3
+ require 'new_relic/agent/datastores'
4
4
  rescue LoadError => e
5
5
  fail LoadError, "Can't use NewRelic instrumentation without NewRelic gem"
6
6
  end
@@ -13,12 +13,32 @@ module Cequel
13
13
  module NewRelicInstrumentation
14
14
  extend ActiveSupport::Concern
15
15
 
16
- included do
17
- include NewRelic::Agent::MethodTracer
16
+ define_method :execute_with_consistency_with_newrelic do |statement, bind_vars, consistency|
17
+ callback = Proc.new do |result, scoped_metric, elapsed|
18
+ NewRelic::Agent::Datastores.notice_statement(statement, elapsed)
19
+ end
20
+
21
+ statement_words = statement.split
22
+ operation = statement_words.first.downcase
23
+ table = nil
24
+ case operation
25
+ when "begin"
26
+ operation = "batch"
27
+ when "select"
28
+ table = statement_words.at(statement_words.index("FROM") + 1)
29
+ when "insert"
30
+ table = statement_words[2]
31
+ when "update"
32
+ table = statement_words[1]
33
+ end
18
34
 
19
- add_method_tracer :execute_with_consistency,
20
- 'Database/Cassandra/#{args[0][/^[A-Z ]*[A-Z]/]' \
21
- '.sub(/ FROM$/, \'\')}'
35
+ NewRelic::Agent::Datastores.wrap("Cassandra", operation, table, callback) do
36
+ execute_with_consistency_without_newrelic(statement, bind_vars, consistency)
37
+ end
38
+ end
39
+
40
+ included do
41
+ alias_method_chain :execute_with_consistency, :newrelic
22
42
  end
23
43
  end
24
44
  end
@@ -32,7 +32,7 @@ module Cequel
32
32
 
33
33
  exploded_key_attributes = [{}].tap do |all_key_attributes|
34
34
  key_columns.zip(scoped_key_values) do |column, values|
35
- all_key_attributes.replace(Array(values).flat_map do |value|
35
+ all_key_attributes.replace([values].flatten.compact.flat_map do |value|
36
36
  all_key_attributes.map do |key_attributes|
37
37
  key_attributes.merge(column.name => value)
38
38
  end
@@ -22,9 +22,9 @@ module Cequel
22
22
  end
23
23
 
24
24
  initializer "cequel.add_new_relic" do
25
- if configuration.fetch(:newrelic_enabled, true)
25
+ if configuration.fetch(:newrelic, true)
26
26
  begin
27
- require 'new_relic/agent/method_tracer'
27
+ require 'new_relic/agent/datastores'
28
28
  rescue LoadError => e
29
29
  Rails.logger.debug(
30
30
  "New Relic not installed; skipping New Relic integration")
@@ -1,5 +1,5 @@
1
1
  # -*- encoding : utf-8 -*-
2
2
  module Cequel
3
3
  # The current version of the library
4
- VERSION = '1.8.0'
4
+ VERSION = '1.9.0'
5
5
  end
@@ -0,0 +1,16 @@
1
+ # -*- encoding : utf-8 -*-
2
+ require File.expand_path('../spec_helper', __FILE__)
3
+
4
+ describe Cequel::Record::LazyRecordCollection do
5
+ context 'handle timestamp attribute correctly (do not split it to array)' do
6
+ model :Event do
7
+ key :timestamp, :timestamp
8
+ column :value, :text
9
+ end
10
+
11
+ let(:now) { Time.now }
12
+ let(:event) { Event[now] }
13
+
14
+ it { expect(event.attributes).to include(timestamp: now) }
15
+ end
16
+ end
@@ -75,6 +75,7 @@ describe Cequel::SpecSupport::Preparation do
75
75
 
76
76
  after(:each) do
77
77
  begin
78
+ Cequel::Record.connection.clear_active_connections!
78
79
  Cequel::Record.connection.schema.create!
79
80
  rescue
80
81
  nil
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: cequel
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.8.0
4
+ version: 1.9.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Mat Brown
@@ -29,7 +29,7 @@ authors:
29
29
  autorequire:
30
30
  bindir: bin
31
31
  cert_chain: []
32
- date: 2016-03-27 00:00:00.000000000 Z
32
+ date: 2016-04-02 00:00:00.000000000 Z
33
33
  dependencies:
34
34
  - !ruby/object:Gem::Dependency
35
35
  name: activemodel
@@ -277,6 +277,7 @@ files:
277
277
  - spec/examples/record/callbacks_spec.rb
278
278
  - spec/examples/record/dirty_spec.rb
279
279
  - spec/examples/record/finders_spec.rb
280
+ - spec/examples/record/lazy_record_collection_spec.rb
280
281
  - spec/examples/record/list_spec.rb
281
282
  - spec/examples/record/map_spec.rb
282
283
  - spec/examples/record/mass_assignment_spec.rb
@@ -336,6 +337,7 @@ test_files:
336
337
  - spec/examples/record/callbacks_spec.rb
337
338
  - spec/examples/record/dirty_spec.rb
338
339
  - spec/examples/record/finders_spec.rb
340
+ - spec/examples/record/lazy_record_collection_spec.rb
339
341
  - spec/examples/record/list_spec.rb
340
342
  - spec/examples/record/map_spec.rb
341
343
  - spec/examples/record/mass_assignment_spec.rb