active_record-mod_sql_log_subscriber 0.1.1 → 0.1.2

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: c54b21fd7a68cb5810c3133e11c170252c498c50ac5ca27636d12ed22a5dd66c
4
- data.tar.gz: 3d1dd5f24f747bd4ec8e16275ceb50f50250113b858b42c958bd993d338166fe
3
+ metadata.gz: 4db0c79ca185a749a8aed8dc821e28f3c7de8ef6932e4069b3dfd904fb588e9e
4
+ data.tar.gz: 80524d959e775f16eef4dd27775e2612f3fe2f6d17d3a64e1e6fbfe1cc4250c5
5
5
  SHA512:
6
- metadata.gz: 679d7aba887b8640ae1fdce95d63ea51b3e2c3c2c0f70695666c9f493f9e0dc4e15a7518fc5666def3511ace0b259e75f99e33cacf04b13547293a23336bf063
7
- data.tar.gz: 587fb2221a219be48a20216faa56c1d3c4ba7afeb43dba7abe485502d715c93671c494bd038daa5c4351a885eb37e39755a86b0d48da6d30643e86eb06efefa7
6
+ metadata.gz: 7d5ec3e856157e2587e39f8d64a66f91eb1ebe094a66c7e533bc41466b4f7bdd2e9841c965ca04db34bce67ae1050444afa51f186b0a229d720737fa218ef387
7
+ data.tar.gz: ed104846206719ec342e6c74df977283eb04b1230bf5d1578275c5e93a46f4daca4f1ba7dec2f54c1aeb0360797a4dd0ff8c78d3fbf728c049588cfe66b69408
data/README.md CHANGED
@@ -25,6 +25,10 @@ The mod-SQL is shown as follows.
25
25
  * I want to write logs only mod-SQL(INSERT, UPDATE, DELETE, ...) and transaction SQL(BEGIN, COMMIT, ROLLBACK, ...).
26
26
  So I create this gem.
27
27
 
28
+ ## Requirements
29
+
30
+ * Rails >= 5.1.5
31
+
28
32
  ## Installation
29
33
 
30
34
  Add this line to your application's Gemfile:
@@ -89,18 +93,18 @@ $ bin/console
89
93
 
90
94
  > User.create!(name: 'name', age: 20, birth_date: Date.new(2000, 1, 1))
91
95
  # => I, [2019-02-05T11:04:07.489057 #42019] INFO -- : begin transaction
92
- # I, [2019-02-05T11:04:07.490495 #42019] INFO -- : INSERT INTO "users" ("name", "age", "birth_date", "created_at", "updated_at") VALUES (?, ?, ?, ?, ?) [["name", "name"], ["age", 20], ["birth_date", "2000-01-01"], ["created_at", "2019-02-05 02:04:07.489226"], ["updated_at", "2019-02-05 02:04:07.489226"]]
96
+ # I, [2019-02-05T11:04:07.490495 #42019] INFO -- : INSERT INTO "users" ("name", "age", "birth_date", "created_at", "updated_at") VALUES (?, ?, ?, ?, ?) ["name", 20, "2000-01-01", "2019-02-20 05:00:13.175405", "2019-02-20 05:00:13.175405"]
93
97
  # I, [2019-02-05T11:04:07.492610 #42019] INFO -- : commit transaction
94
98
 
95
99
  > user = User.last # => no log
96
100
  > user.update_attributes(name: 'new name')
97
101
  # => I, [2019-02-05T11:04:52.971503 #42019] INFO -- : begin transaction
98
- # I, [2019-02-05T11:04:52.973071 #42019] INFO -- : UPDATE "users" SET "name" = ?, "updated_at" = ? WHERE "users"."id" = ? [["name", "new name"], ["updated_at", "2019-02-05 02:04:52.971865"], ["id", 2]]
102
+ # I, [2019-02-05T11:04:52.973071 #42019] INFO -- : UPDATE "users" SET "name" = ?, "updated_at" = ? WHERE "users"."id" = ? ["new name", "2019-02-20 05:00:37.983816", 2]
99
103
  # I, [2019-02-05T11:04:52.974081 #42019] INFO -- : commit transaction
100
104
 
101
105
  > user.destroy
102
106
  # => I, [2019-02-05T11:05:13.765564 #42019] INFO -- : begin transaction
103
- # I, [2019-02-05T11:05:13.775460 #42019] INFO -- : DELETE FROM "users" WHERE "users"."id" = ? [["id", 2]]
107
+ # I, [2019-02-05T11:05:13.775460 #42019] INFO -- : DELETE FROM "users" WHERE "users"."id" = ? [2]
104
108
  # I, [2019-02-05T11:05:13.776722 #42019] INFO -- : commit transaction
105
109
  ```
106
110
 
@@ -10,7 +10,7 @@ module ActiveRecord
10
10
  class ModSqlLogSubscriber < ::ActiveRecord::LogSubscriber
11
11
  include ActiveSupport::Configurable
12
12
 
13
- VERSION = "0.1.1"
13
+ VERSION = "0.1.2"
14
14
 
15
15
  config_accessor :disable, :log_level, :log_format, :target_statements
16
16
 
@@ -31,7 +31,7 @@ module ActiveRecord
31
31
  return if IGNORE_PAYLOAD_NAMES.include?(payload[:name])
32
32
  return unless target_sql_checker.match?(sql)
33
33
 
34
- binds = extract_binds(payload)
34
+ binds = type_casted_binds(payload[:type_casted_binds])
35
35
  send(self.log_level, formatter.call(sql, binds))
36
36
  end
37
37
 
@@ -41,18 +41,6 @@ module ActiveRecord
41
41
  @target_sql_checker ||= /\A\s*(#{self.target_statements.join('|')})/mi
42
42
  end
43
43
 
44
- def extract_binds(payload)
45
- binds = []
46
- unless (payload[:binds] || []).empty?
47
- casted_params = type_casted_binds(payload[:type_casted_binds])
48
- payload[:binds].zip(casted_params).map do |attr, value|
49
- key, val = render_bind(attr, value)
50
- binds << [key, val]
51
- end
52
- end
53
- binds
54
- end
55
-
56
44
  def formatter
57
45
  @formatter ||=
58
46
  case self.log_format
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: active_record-mod_sql_log_subscriber
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.1
4
+ version: 0.1.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - ryu39
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2019-02-05 00:00:00.000000000 Z
11
+ date: 2019-02-20 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activesupport