cequel 1.3.1 → 1.3.2

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: 8ee94e15c942005f32077593e9518db59d425ec8
4
- data.tar.gz: a8509b1748bc988890d99520bce4d2a89b1c0c86
3
+ metadata.gz: 6143aa040bd563d95f997e29285ec19dc636e2ff
4
+ data.tar.gz: 9c91d530af0b021624b83ee1d4bc0081428a5b4d
5
5
  SHA512:
6
- metadata.gz: 9c689b0b7db31b588fdc41d750b7e718cf472b72862cf76f372f3ceb1ddafe38b19e786c960fb4cdfaaba3d8249cdf68ff676ef3b521070230e0bef18fce30ae
7
- data.tar.gz: 3df5b7b2591cf860f064c56cfcfa4e68b27e95317725301e0699d6972693f4f9b7195b316766c8b896c8abd9726657bb924f54b208a915e221d6d296475c7744
6
+ metadata.gz: 0c66344642c23a1551c924c88ccaace992be584a2bb8555a5c61da97e6ce641bd624300e1ce4ba3ae6ce10431d4b4750db01ed531aa524aa153a024bc7fee6d1
7
+ data.tar.gz: 6491fc3e289cea01be5125ae4829789266221538799e09d9e221820d487d3026a9c612d892bc80b60b3b63dc51b1bb1766692a4439f06ba9256032243e561a75
@@ -1,3 +1,7 @@
1
+ ## 1.3.2
2
+
3
+ * Cast values passed to primary key filters in record sets
4
+
1
5
  ## 1.3.1
2
6
 
3
7
  * Allow querying by both primary key and secondary index in `RecordSet`
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- cequel (1.3.1)
4
+ cequel (1.3.2)
5
5
  activemodel (>= 3.1, < 5.0)
6
6
  cql-rb (>= 1.2, < 3.0)
7
7
 
@@ -727,7 +727,9 @@ module Cequel
727
727
  if value.is_a?(Range)
728
728
  self.in(value)
729
729
  else
730
- scoped { |attributes| attributes[:scoped_key_values] << value }
730
+ scoped do |attributes|
731
+ attributes[:scoped_key_values] << cast_next_primary_key(value)
732
+ end
731
733
  end
732
734
  end
733
735
 
@@ -900,6 +902,14 @@ module Cequel
900
902
  yield record.key_attributes
901
903
  end
902
904
  end
905
+
906
+ def cast_next_primary_key(value)
907
+ if value.is_a?(Array)
908
+ value.map { |element| next_unscoped_key_column.cast(element) }
909
+ else
910
+ next_unscoped_key_column.cast(value)
911
+ end
912
+ end
903
913
  end
904
914
  end
905
915
  end
@@ -1,5 +1,5 @@
1
1
  # -*- encoding : utf-8 -*-
2
2
  module Cequel
3
3
  # The current version of the library
4
- VERSION = '1.3.1'
4
+ VERSION = '1.3.2'
5
5
  end
@@ -16,7 +16,7 @@ describe Cequel::Record::Finders do
16
16
 
17
17
  model :Post do
18
18
  key :blog_subdomain, :text
19
- key :permalink, :text
19
+ key :id, :timeuuid, auto: true
20
20
  column :title, :text
21
21
  column :body, :text
22
22
  column :author_id, :uuid, index: true
@@ -37,7 +37,6 @@ describe Cequel::Record::Finders do
37
37
  5.times.map do |i|
38
38
  Post.create!(
39
39
  blog_subdomain: 'cassandra',
40
- permalink: "cassandra#{i}",
41
40
  author_id: author_ids[i%2]
42
41
  )
43
42
  end
@@ -47,7 +46,7 @@ describe Cequel::Record::Finders do
47
46
  let :postgres_posts do
48
47
  cequel.batch do
49
48
  5.times.map do |i|
50
- Post.create!(blog_subdomain: 'postgres', permalink: "postgres#{i}")
49
+ Post.create!(blog_subdomain: 'postgres')
51
50
  end
52
51
  end
53
52
  end
@@ -113,15 +112,20 @@ describe Cequel::Record::Finders do
113
112
  end
114
113
 
115
114
  it 'should not exist for all keys' do
116
- expect { Post.find_all_by_blog_subdomain_and_permalink('f', 'b') }
115
+ expect { Post.find_all_by_blog_subdomain_and_id('f', Cequel.uuid) }
117
116
  .to raise_error(NoMethodError)
118
117
  end
119
118
  end
120
119
 
121
120
  describe '#find_by_*' do
122
121
  it 'should return record matching all keys' do
123
- expect(Post.find_by_blog_subdomain_and_permalink('cassandra',
124
- 'cassandra0'))
122
+ expect(Post.find_by_blog_subdomain_and_id(
123
+ 'cassandra', cassandra_posts.first.id)).to eq(cassandra_posts.first)
124
+ end
125
+
126
+ it 'should cast arguments to correct type' do
127
+ expect(Post.find_by_blog_subdomain_and_id(
128
+ 'cassandra', cassandra_posts.first.id.to_s))
125
129
  .to eq(cassandra_posts.first)
126
130
  end
127
131
 
@@ -132,14 +136,21 @@ describe Cequel::Record::Finders do
132
136
 
133
137
  it 'should allow lower-order key if chained' do
134
138
  expect(Post.where(blog_subdomain: 'cassandra')
135
- .find_by_permalink('cassandra0')).to eq(cassandra_posts.first)
139
+ .find_by_id(cassandra_posts.first.id))
140
+ .to eq(cassandra_posts.first)
136
141
  end
137
142
  end
138
143
 
139
144
  describe '#with_*' do
140
145
  it 'should return record matching all keys' do
141
- expect(Post.with_blog_subdomain_and_permalink('cassandra',
142
- 'cassandra0'))
146
+ expect(Post.with_blog_subdomain_and_id('cassandra',
147
+ cassandra_posts.first.id))
148
+ .to eq(cassandra_posts.first(1))
149
+ end
150
+
151
+ it 'should cast arguments to correct type' do
152
+ expect(Post.with_blog_subdomain_and_id('cassandra',
153
+ cassandra_posts.first.id.to_s))
143
154
  .to eq(cassandra_posts.first(1))
144
155
  end
145
156
 
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.3.1
4
+ version: 1.3.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Mat Brown
@@ -20,7 +20,7 @@ authors:
20
20
  autorequire:
21
21
  bindir: bin
22
22
  cert_chain: []
23
- date: 2014-05-30 00:00:00.000000000 Z
23
+ date: 2014-06-02 00:00:00.000000000 Z
24
24
  dependencies:
25
25
  - !ruby/object:Gem::Dependency
26
26
  name: activemodel