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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 2f86e2b6f4010783ee6fc62f702db39f9d54ddda
4
- data.tar.gz: 31356a4ef22c64607f574735c2b1e4ae717fd150
3
+ metadata.gz: 83c50053063595b07ec25edb5c847006eaa12ed8
4
+ data.tar.gz: 574cce3d4c75fe7150bb647abdfc1baa2c68a666
5
5
  SHA512:
6
- metadata.gz: 05fe7123a01eb31a9cc27823853f0362fa105b6d4332082ec0fb5e0544e215d04ca43533013abaaf55f21a1d798ab85942fbd594c6d3a4936b24c26fc8567a52
7
- data.tar.gz: 8a9b2e652fdf6343f9a3f40a8875ab7151d51d94fcf6c46105d4056b7eb73ac943cc71eba66207e0be8e668c51fa4c482cf8c22ce24cd9e716af075a72c1469b
6
+ metadata.gz: 5d45ddd9e7368275d347b8104849a41de8ad1db6ecd1e5811e1bb8ad88cbdd9fa19df92fcbe8bafed2cf46bc147d5981202eca0875423f6a753ac756d09c18f0
7
+ data.tar.gz: 35a041419ee196ddb8c8acd06f523fa0b808c9ad109f99122792bcda0bea2ef76f65a3420b455327092f5c2a39e1029285ff066cd1a9e5f10b9aa99f8702e0cb
@@ -1,3 +1,7 @@
1
+ ## 1.2.4
2
+
3
+ * Apply empty attribute values when hydrating records
4
+
1
5
  ## 1.2.3
2
6
 
3
7
  * Fix intermittent load failures of activesupport 4.0.x
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- cequel (1.2.3)
4
+ cequel (1.2.4)
5
5
  activemodel (>= 3.1, < 5.0)
6
6
  cql-rb (~> 1.2)
7
7
 
@@ -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).__send__(:hydrated!)
62
+ new_empty.hydrate(row)
57
63
  end
58
64
 
59
65
  # @private
@@ -1,5 +1,5 @@
1
1
  # -*- encoding : utf-8 -*-
2
2
  module Cequel
3
3
  # The current version of the library
4
- VERSION = '1.2.3'
4
+ VERSION = '1.2.4'
5
5
  end
@@ -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.3
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-14 00:00:00.000000000 Z
21
+ date: 2014-04-23 00:00:00.000000000 Z
22
22
  dependencies:
23
23
  - !ruby/object:Gem::Dependency
24
24
  name: activemodel