cequel 1.3.1 → 1.3.2
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/CHANGELOG.md +4 -0
- data/Gemfile.lock +1 -1
- data/lib/cequel/record/record_set.rb +11 -1
- data/lib/cequel/version.rb +1 -1
- data/spec/examples/record/finders_spec.rb +20 -9
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 6143aa040bd563d95f997e29285ec19dc636e2ff
|
4
|
+
data.tar.gz: 9c91d530af0b021624b83ee1d4bc0081428a5b4d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 0c66344642c23a1551c924c88ccaace992be584a2bb8555a5c61da97e6ce641bd624300e1ce4ba3ae6ce10431d4b4750db01ed531aa524aa153a024bc7fee6d1
|
7
|
+
data.tar.gz: 6491fc3e289cea01be5125ae4829789266221538799e09d9e221820d487d3026a9c612d892bc80b60b3b63dc51b1bb1766692a4439f06ba9256032243e561a75
|
data/CHANGELOG.md
CHANGED
data/Gemfile.lock
CHANGED
@@ -727,7 +727,9 @@ module Cequel
|
|
727
727
|
if value.is_a?(Range)
|
728
728
|
self.in(value)
|
729
729
|
else
|
730
|
-
scoped
|
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
|
data/lib/cequel/version.rb
CHANGED
@@ -16,7 +16,7 @@ describe Cequel::Record::Finders do
|
|
16
16
|
|
17
17
|
model :Post do
|
18
18
|
key :blog_subdomain, :text
|
19
|
-
key :
|
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'
|
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.
|
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.
|
124
|
-
|
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
|
-
.
|
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.
|
142
|
-
|
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.
|
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-
|
23
|
+
date: 2014-06-02 00:00:00.000000000 Z
|
24
24
|
dependencies:
|
25
25
|
- !ruby/object:Gem::Dependency
|
26
26
|
name: activemodel
|