octoball 0.1.3 → 0.1.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
  SHA256:
3
- metadata.gz: 79b000766e9d706b1d98717665279bfd6fd7302b6f0e55dd675658cbd5477674
4
- data.tar.gz: f083a86147e3c7942fbbf042b2f82358576d9b5d2e696e2b4a872a2595eb252f
3
+ metadata.gz: 260d7c95bac1ba724636272cfa7ecf444124b868b2c7a3cea4d6966e0ac947a9
4
+ data.tar.gz: 5036fc1b1f6f5f0d7b24c734951ad6cbff0fd48eabc529a3f5390e55f2ad50d2
5
5
  SHA512:
6
- metadata.gz: 0c24fa278965d1202d0905f8b37b3d42845789b6e1fe6145426c7a1760c88fec3cb380ce080d5d401b7f951c879055da557d33e3575a2cc06796d517d45dd5af
7
- data.tar.gz: 7d5e45681650dcbe9aa640242a0c0c86a290e82ca095698f91a56866e527ffcbe113f91a1e764a52a5c720f6c12d210f62900091e7203cbbf9f9d3848886bc8a
6
+ metadata.gz: 1d954e47f0a2603425d29e82669b9388d4f49abf7def04e268548554ee5ab52181a2b192a5ccfd34b288a67b34fd6cf8cac4d75b8304c918970f7523f3177285
7
+ data.tar.gz: 7b294deea783c80324d5694afd87984017411677f593d042fa9b78a35e5dba5d12584209bb36d45190c3e63d748e1a4f5096e6a6e992ef9ebfa71e7968a41c4d
data/.circleci/Gemfile ADDED
@@ -0,0 +1,8 @@
1
+ source 'https://rubygems.org'
2
+
3
+ if RUBY_VERSION < '3.0'
4
+ gem 'activerecord', '~> 6.1.0'
5
+ gem 'activesupport', '~> 6.1.0'
6
+ end
7
+
8
+ gemspec :path => '../'
data/.circleci/config.yml CHANGED
@@ -26,8 +26,9 @@ jobs:
26
26
  name: bundle install
27
27
  command: |
28
28
  gem update bundler
29
+ bundle config --local path ../vendor/bundle
30
+ bundle install --gemfile .circleci/Gemfile --jobs=4 --retry=3
29
31
  bundle config --local path vendor/bundle
30
- bundle install --jobs=4 --retry=3
31
32
  - run:
32
33
  name: Setup databases
33
34
  command: bundle exec rake db:prepare
@@ -44,3 +45,4 @@ workflows:
44
45
  parameters:
45
46
  version:
46
47
  - "2.7"
48
+ - "3.0"
@@ -5,6 +5,12 @@ class Octoball
5
5
  attr_accessor :current_shard
6
6
  end
7
7
 
8
+ module RelationProxyIsARelation
9
+ def ===(other)
10
+ other.is_a?(self)
11
+ end
12
+ end
13
+
8
14
  module ShardedCollectionAssociation
9
15
  [:writer, :ids_reader, :ids_writer, :create, :create!,
10
16
  :build, :include?, :load_target, :reload, :size, :select].each do |method|
@@ -71,6 +77,7 @@ class Octoball
71
77
  end
72
78
 
73
79
  ::ActiveRecord::Relation.prepend(RelationCurrentShard)
80
+ ::ActiveRecord::Relation.singleton_class.prepend(RelationProxyIsARelation)
74
81
  ::ActiveRecord::QueryMethods::WhereChain.prepend(RelationCurrentShard)
75
82
  ::ActiveRecord::Associations::CollectionAssociation.prepend(ShardedCollectionAssociation)
76
83
  ::ActiveRecord::Associations::CollectionProxy.singleton_class.prepend(ShardedCollectionProxyCreate)
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  class Octoball
4
- VERSION = '0.1.3'
4
+ VERSION = '0.1.4'
5
5
  end
@@ -52,6 +52,20 @@ describe Octoball::RelationProxy do
52
52
  end
53
53
  end
54
54
 
55
+ context 'when a relation is used in where clause' do
56
+ it 'specifies the scope without a shard' do
57
+ client = Client.where(id: @client.id)
58
+ items = Item.using(:canada).where(client: client)
59
+ expect(items.to_a).to eq(@client.items.to_a)
60
+ end
61
+
62
+ it 'specifies the scope with a shard' do
63
+ client = Client.using(:canada).where(id: @client.id)
64
+ items = Item.using(:canada).where(client: client)
65
+ expect(items.to_a).to eq(@client.items.to_a)
66
+ end
67
+ end
68
+
55
69
  context 'when comparing to other Relation objects' do
56
70
  before :each do
57
71
  @relation.reset
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: octoball
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.3
4
+ version: 0.1.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Tomoki Sekiyama
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2021-05-31 00:00:00.000000000 Z
11
+ date: 2021-12-24 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activerecord
@@ -116,6 +116,7 @@ executables: []
116
116
  extensions: []
117
117
  extra_rdoc_files: []
118
118
  files:
119
+ - ".circleci/Gemfile"
119
120
  - ".circleci/config.yml"
120
121
  - ".gitignore"
121
122
  - Gemfile
@@ -167,7 +168,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
167
168
  - !ruby/object:Gem::Version
168
169
  version: '0'
169
170
  requirements: []
170
- rubygems_version: 3.1.4
171
+ rubygems_version: 3.1.6
171
172
  signing_key:
172
173
  specification_version: 4
173
174
  summary: Octopus-like Database Sharding Helper for ActiveRecord 6.1+