pgpool_no_load_balance 1.0.3 → 1.1.0

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: d372d723de84f85915542bfb4fc837a23605c0029079441e0361e48910df68af
4
- data.tar.gz: 7dc3328d6936cf6920dd273df573c2e55f88be9159bbc60013eb35a27de3146b
3
+ metadata.gz: 140d4448dd6fb7939e899a8ce16a612a2464dd71a74d07e385de89f77a8cc592
4
+ data.tar.gz: ae1a1c76853f41b66905635040a6e2f5bb99cc37d87d003bef3d7dbebbd16038
5
5
  SHA512:
6
- metadata.gz: 46423f6a6f8a8b3847d999926e920e24cdc8923194b2d7b3349b0676c08c55ae415d5b3b2b1afe32cc96f05abe898a7db6fbea67479e50392c932cab18e7defd
7
- data.tar.gz: e624bfe2987b3ee4f3adafb61ee71eb64be5cac9c648afd263b59e44f971e66444b959169c3ae813a9ec12a0fc77b4ac62b03b144fedb24401d1560e0fb34444
6
+ metadata.gz: b7ce67970675febfe3e2c132c3e333d8aaf67c4cbfc036fe2614579885168dc1bc43eaf7696ba171d1c97a4bb82d4f70dde280d8da61e7da9a4cee885005a030
7
+ data.tar.gz: d10ede5d40c35c54c37e8c134b439f1df197069d5c936bf564fdd3c6b7deab6c9c120772b20a4017888ed56d67b57e7b79eaf394f0c0bab11b3942f121ece399
data/.gitignore CHANGED
@@ -8,6 +8,7 @@
8
8
  /tmp/
9
9
  /vendor/
10
10
  Gemfile.lock
11
+ /.vscode/
11
12
 
12
13
  # rspec failure tracking
13
14
  .rspec_status
@@ -22,15 +22,19 @@ straightforward as possible.
22
22
 
23
23
  ### Security
24
24
 
25
+ ## [1.1.0] - 2020-06-14
26
+
27
+ Executes any SQL statement with comments.
28
+
29
+ ### Added
30
+ - Added pgpool_nlb option to AR #execute.
31
+
25
32
  ## [1.0.3] - 2020-05-05
26
33
 
27
34
  for RubyGems release.
28
35
 
29
36
  ## [1.0.2] - 2020-05-05
30
37
 
31
- Here we write upgrading notes for brands. It's a team effort to make them as
32
- straightforward as possible.
33
-
34
38
  ### Added
35
39
  - Adapter check feature. (PostgreSQLAdapterMissing exception is raised if the application is not using the Postgresql adaptor.)
36
40
 
data/README.md CHANGED
@@ -8,24 +8,29 @@ If you don't want a query that qualifies for the load balancing to be load balan
8
8
 
9
9
  Add this line to your application's Gemfile:
10
10
 
11
- ```ruby
11
+ ```rb
12
12
  gem 'pgpool_no_load_balance'
13
13
  ```
14
14
 
15
15
  And then execute:
16
16
 
17
- $ bundle install
17
+ ```console
18
+ $ bundle install
19
+ ```
18
20
 
19
21
  Or install it yourself as:
20
22
 
21
- $ gem install pgpool_no_load_balance
23
+ ```console
24
+ $ gem install pgpool_no_load_balance
25
+ ```
22
26
 
23
27
  ## Usage
24
28
 
25
29
  ### pgpool_nlb method
26
30
 
27
31
  Using the `pgpool_nlb` method will add a comment to the SQL.
28
- ```irb
32
+
33
+ ```rb
29
34
  irb(main):001:0> User.pgpool_nlb.all
30
35
  /*NO LOAD BALANCE*/ SELECT "users".* FROM "users" LIMIT $1 [["LIMIT", 11]]
31
36
  ```
@@ -33,18 +38,32 @@ irb(main):001:0> User.pgpool_nlb.all
33
38
  ### unscope
34
39
 
35
40
  Can remove the scope with the unscope method.
36
- ```irb
41
+
42
+ ```rb
37
43
  irb(main):001:0> user_relation = User.where(name: 'elengine').pgpool_nlb
44
+
38
45
  irb(main):002:0> user_relation.count
39
46
  /*NO LOAD BALANCE*/ SELECT COUNT(*) FROM "users" WHERE "users"."name" = $1 [["name", "elengine"]]
47
+
40
48
  irb(main):003:0> user_relation.unscope(:pgpool_nlb).order(:id).limit(3)
41
49
  SELECT "users".* FROM "users" WHERE "users"."name" = $1 ORDER BY "users"."id" ASC LIMIT $2 [["name", "elengine"], ["LIMIT", 3]]
42
50
  ```
43
51
 
44
- ## Contributing
52
+ ### Arbitrary SQL execution
53
+
54
+ Using the `pgpool_nlb` option of the execute method will add a comment to the SQL.
55
+
56
+ ```rb
57
+ irb(main):001:0> ActiveRecord::Base.connection.execute('SELECT 1')
58
+ SELECT 1
45
59
 
46
- Bug reports and pull requests are welcome on GitHub at https://github.com/elengine/pgpool_no_load_balance. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [code of conduct](https://github.com/elengine/pgpool_no_load_balance/blob/master/CODE_OF_CONDUCT.md).
60
+ irb(main):002:0> ActiveRecord::Base.connection.execute('SELECT 1', pgpool_nlb: true)
61
+ /*NO LOAD BALANCE*/ SELECT 1
62
+ ```
63
+
64
+ ## Contributing
47
65
 
66
+ Bug reports and pull requests are welcome on GitHub at <https://github.com/elengine/pgpool_no_load_balance>. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [code of conduct](https://github.com/elengine/pgpool_no_load_balance/blob/master/CODE_OF_CONDUCT.md).
48
67
 
49
68
  ## License
50
69
 
@@ -2,6 +2,10 @@ module PgpoolNoLoadBalance
2
2
  module ActiveRecord
3
3
  module ConnectionAdapters
4
4
  module PostgreSQLAdapter
5
+ def execute(sql, name = nil, pgpool_nlb: false)
6
+ sql = "#{NLB_COMMENT} #{sql}" if !!pgpool_nlb
7
+ super sql, name
8
+ end
5
9
 
6
10
  private
7
11
 
@@ -1,3 +1,3 @@
1
1
  module PgpoolNoLoadBalance
2
- VERSION = "1.0.3"
2
+ VERSION = "1.1.0"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: pgpool_no_load_balance
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.3
4
+ version: 1.1.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - elengine
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2020-05-05 00:00:00.000000000 Z
11
+ date: 2020-06-14 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activerecord