cequel 1.2.3 → 1.2.4
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +4 -0
- data/Gemfile.lock +1 -1
- data/lib/cequel/record/persistence.rb +7 -1
- data/lib/cequel/version.rb +1 -1
- data/spec/examples/record/record_set_spec.rb +67 -0
- 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: 83c50053063595b07ec25edb5c847006eaa12ed8
|
4
|
+
data.tar.gz: 574cce3d4c75fe7150bb647abdfc1baa2c68a666
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 5d45ddd9e7368275d347b8104849a41de8ad1db6ecd1e5811e1bb8ad88cbdd9fa19df92fcbe8bafed2cf46bc147d5981202eca0875423f6a753ac756d09c18f0
|
7
|
+
data.tar.gz: 35a041419ee196ddb8c8acd06f523fa0b808c9ad109f99122792bcda0bea2ef76f65a3420b455327092f5c2a39e1029285ff066cd1a9e5f10b9aa99f8702e0cb
|
data/CHANGELOG.md
CHANGED
data/Gemfile.lock
CHANGED
@@ -51,9 +51,15 @@ module Cequel
|
|
51
51
|
connection[table_name]
|
52
52
|
end
|
53
53
|
|
54
|
+
# @return [Cequel::Record] a new instance of this record class
|
55
|
+
# populated with the attributes from `row`
|
56
|
+
#
|
57
|
+
# @param row [Hash] attributes from the database with which
|
58
|
+
# the new instance should be populated.
|
59
|
+
#
|
54
60
|
# @private
|
55
61
|
def hydrate(row)
|
56
|
-
new_empty(row)
|
62
|
+
new_empty.hydrate(row)
|
57
63
|
end
|
58
64
|
|
59
65
|
# @private
|
data/lib/cequel/version.rb
CHANGED
@@ -362,6 +362,73 @@ describe Cequel::Record::RecordSet do
|
|
362
362
|
Post.find_each(:batch_size => 2).map(&:title).should =~
|
363
363
|
(0...5).flat_map { |i| ["Cequel #{i}", "Sequel #{i}", "Mongoid #{i}"] }
|
364
364
|
end
|
365
|
+
|
366
|
+
describe "hydration" do
|
367
|
+
subject { x = nil
|
368
|
+
Post.find_each(:batch_size => 2){|it| x = it; break}
|
369
|
+
x
|
370
|
+
}
|
371
|
+
|
372
|
+
it 'should hydrate empty lists properly' do
|
373
|
+
expect(subject.tags).to eq []
|
374
|
+
end
|
375
|
+
|
376
|
+
it 'should hydrate empty sets properly' do
|
377
|
+
expect(subject.categories).to eq ::Set[]
|
378
|
+
end
|
379
|
+
|
380
|
+
it 'should hydrate empty maps properly' do
|
381
|
+
expect(subject.shares).to eq Hash.new
|
382
|
+
end
|
383
|
+
end
|
384
|
+
end
|
385
|
+
|
386
|
+
describe '#find_in_batches' do
|
387
|
+
let!(:records) { [posts, blogs, mongo_posts] }
|
388
|
+
|
389
|
+
it 'should respect :batch_size argument' do
|
390
|
+
cequel.should_receive(:execute_with_consistency).twice.and_call_original
|
391
|
+
Blog.find_in_batches(:batch_size => 2){|a_batch| next }
|
392
|
+
end
|
393
|
+
|
394
|
+
it 'should iterate over all keys' do
|
395
|
+
expected_posts = (posts + mongo_posts)
|
396
|
+
found_posts = []
|
397
|
+
|
398
|
+
Post.find_in_batches(:batch_size => 2) {|recs|
|
399
|
+
expect(recs).to be_kind_of Array
|
400
|
+
found_posts += recs
|
401
|
+
}
|
402
|
+
expect(found_posts).to include(*expected_posts)
|
403
|
+
expect(found_posts).to have(expected_posts.size).items
|
404
|
+
end
|
405
|
+
|
406
|
+
it 'should iterate over batches' do
|
407
|
+
expected_posts = (posts + mongo_posts)
|
408
|
+
|
409
|
+
expect{|blk| Post.find_in_batches(:batch_size => 2, &blk)}
|
410
|
+
.to yield_control.at_least(expected_posts.size / 2).times
|
411
|
+
end
|
412
|
+
|
413
|
+
|
414
|
+
describe "hydration" do
|
415
|
+
subject { x = nil
|
416
|
+
Post.find_each(:batch_size => 2){|it| x = it; break}
|
417
|
+
x
|
418
|
+
}
|
419
|
+
|
420
|
+
it 'should hydrate empty lists properly' do
|
421
|
+
expect(subject.tags).to eq []
|
422
|
+
end
|
423
|
+
|
424
|
+
it 'should hydrate empty sets properly' do
|
425
|
+
expect(subject.categories).to eq ::Set[]
|
426
|
+
end
|
427
|
+
|
428
|
+
it 'should hydrate empty maps properly' do
|
429
|
+
expect(subject.shares).to eq Hash.new
|
430
|
+
end
|
431
|
+
end
|
365
432
|
end
|
366
433
|
|
367
434
|
describe '#find' do
|
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.2.
|
4
|
+
version: 1.2.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Mat Brown
|
@@ -18,7 +18,7 @@ authors:
|
|
18
18
|
autorequire:
|
19
19
|
bindir: bin
|
20
20
|
cert_chain: []
|
21
|
-
date: 2014-04-
|
21
|
+
date: 2014-04-23 00:00:00.000000000 Z
|
22
22
|
dependencies:
|
23
23
|
- !ruby/object:Gem::Dependency
|
24
24
|
name: activemodel
|