iron_trail 0.3.0.pre.alpha2 → 0.3.0.pre.alpha3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 93a89936a73c9adda2859dc0efed14fe01dca6660492d052059632dd538353e4
4
- data.tar.gz: c96fc6cfc41206aa320ac8c7ea8901ec53b74114d60adc8cd3bf100b68c52b22
3
+ metadata.gz: 25117e0591f067570aa8feed5b58cde1c01c09a0fdb386b48fe80e9349684ac4
4
+ data.tar.gz: e73f15bcc8bb2c2e26e6a1f9de39ecf6517e1f60489d9a795df863c0e082c207
5
5
  SHA512:
6
- metadata.gz: 5771fd86323e2166e29d9bb35deb599c740d6e75c36f936781d1a299a9584f8b1318b168eaef58b225a764146d02ec07221e3d3e9c1fb3d086be6ff5c3d0ba98
7
- data.tar.gz: 2e4ed3d32fb33b0ed5f4a98e1a2e7036408b3db5c4bd557e3508f343e5859ba0d3a39118dca0143296797db0e998211300422452afd5225fd546e18ac53d4adc
6
+ metadata.gz: 87ae15bd0c12904c32d7bc10d4d89eb8a50e719a0ca3eb518bebf42eef5383c860eb165251bb8406a3ae63497541e3cdbf676066f1e3fa354af7bb07d28b15a0
7
+ data.tar.gz: 975ba22ccae12a3d90f9b7fbb35cc837b1c2d93c7fbbb1abe271724f62480450b72c8999fcfcc640079c7646e26539967cee504674ec8caba370ec66e65caa09
@@ -66,7 +66,9 @@ module IronTrail
66
66
  # This works by inspecting whether there are any keys in the rec_delta column
67
67
  # other than the columns specified in the `columns` parameter.
68
68
  def with_delta_other_than(*columns)
69
- quoted_columns = columns.map { |col_name| lease_connection.quote(col_name) }
69
+ quoted_columns = with_connection do |conn|
70
+ columns.map { |col_name| conn.quote(col_name) }
71
+ end
70
72
  exclude_array = "ARRAY[#{quoted_columns.join(', ')}]::text[]"
71
73
 
72
74
  sql = "rec_delta IS NULL OR (rec_delta - #{exclude_array}) <> '{}'::jsonb"
@@ -79,17 +81,19 @@ module IronTrail
79
81
  ary_index = Integer(ary_index)
80
82
  scope = all
81
83
 
82
- args.each do |col_name, value|
83
- col_delta = "rec_delta->#{lease_connection.quote(col_name)}"
84
- node = if value == nil
85
- ::Arel::Nodes::SqlLiteral.new("#{col_delta}->#{ary_index} = 'null'::jsonb")
86
- else
87
- ::Arel::Nodes::SqlLiteral.new("#{col_delta}->>#{ary_index}").eq(
88
- ::Arel::Nodes::BindParam.new(value.to_s)
89
- )
84
+ with_connection do |conn|
85
+ args.each do |col_name, value|
86
+ col_delta = "rec_delta->#{conn.quote(col_name)}"
87
+ node = if value == nil
88
+ ::Arel::Nodes::SqlLiteral.new("#{col_delta}->#{ary_index} = 'null'::jsonb")
89
+ else
90
+ ::Arel::Nodes::SqlLiteral.new("#{col_delta}->>#{ary_index}").eq(
91
+ ::Arel::Nodes::BindParam.new(value.to_s)
92
+ )
93
+ end
94
+
95
+ scope.where!(node)
90
96
  end
91
-
92
- scope.where!(node)
93
97
  end
94
98
 
95
99
  scope
@@ -1,5 +1,5 @@
1
1
  # frozen_literal_string: true
2
2
 
3
3
  module IronTrail
4
- VERSION = '0.3.0-alpha2'
4
+ VERSION = '0.3.0-alpha3'
5
5
  end
@@ -2,8 +2,8 @@
2
2
 
3
3
  module IronTrail::RakeHelper
4
4
  class << self
5
- def db_functions
6
- IronTrail::DbFunctions.new(ActiveRecord::Base.connection)
5
+ def db_functions(connection)
6
+ IronTrail::DbFunctions.new(connection)
7
7
  end
8
8
 
9
9
  def abort_when_unsafe!
@@ -22,28 +22,33 @@ namespace :iron_trail do
22
22
  namespace :tracking do
23
23
  desc 'Enables tracking for all missing tables.'
24
24
  task enable: :environment do
25
- tables = IronTrail::RakeHelper.db_functions.collect_tables_tracking_status[:missing]
26
- unless tables.length > 0
27
- puts "All tables are being tracked already (no missing tables found)."
28
- puts "If you think this is wrong, check your ignored_tables list."
29
- return
30
- end
31
-
32
- puts "Will start tracking #{tables.length} tables."
33
- tables.each do |table_name|
34
- IronTrail::RakeHelper.db_functions.enable_tracking_for_table(table_name)
25
+ ActiveRecord::Base.with_connection do |conn|
26
+ db_functions = IronTrail::RakeHelper.db_functions(conn)
27
+ tables = db_functions.collect_tables_tracking_status[:missing]
28
+
29
+ if tables.empty?
30
+ puts "All tables are being tracked already (no missing tables found)."
31
+ puts "If you think this is wrong, check your ignored_tables list."
32
+ else
33
+ puts "Will start tracking #{tables.length} tables."
34
+ tables.each do |table_name|
35
+ db_functions.enable_tracking_for_table(table_name)
36
+ end
37
+ end
35
38
  end
36
39
  end
37
40
 
38
41
  desc 'Disabled tracking for any ignored table that might still have the trigger enabled.'
39
42
  task disable_on_ignored: :environment do
40
- affected_tables = IronTrail::RakeHelper.db_functions.disable_for_all_ignored_tables
43
+ ActiveRecord::Base.with_connection do |conn|
44
+ affected_tables = IronTrail::RakeHelper.db_functions(conn).disable_for_all_ignored_tables
41
45
 
42
- unless affected_tables.empty?
43
- puts "Removed tracking from #{affected_tables.length} tables:"
46
+ unless affected_tables.empty?
47
+ puts "Removed tracking from #{affected_tables.length} tables:"
44
48
 
45
- affected_tables.each do |table_name|
46
- puts "\t#{table_name}"
49
+ affected_tables.each do |table_name|
50
+ puts "\t#{table_name}"
51
+ end
47
52
  end
48
53
  end
49
54
  end
@@ -52,24 +57,30 @@ namespace :iron_trail do
52
57
  task disable: :environment do
53
58
  IronTrail::RakeHelper.abort_when_unsafe!
54
59
 
55
- tables = IronTrail::RakeHelper.db_functions.collect_tables_tracking_status[:tracked]
56
- puts "Will stop tracking #{tables.length} tables."
57
- tables.each do |table_name|
58
- IronTrail::RakeHelper.db_functions.disable_tracking_for_table(table_name)
59
- end
60
+ ActiveRecord::Base.with_connection do |conn|
61
+ db_functions = IronTrail::RakeHelper.db_functions(conn)
60
62
 
61
- tables = IronTrail::RakeHelper.db_functions.collect_tables_tracking_status[:tracked]
62
- if tables.length > 0
63
- puts "WARNING: Something went wrong. There are still #{tables.length}" + \
64
- " tables being tracked."
65
- else
66
- puts "Done!"
63
+ tables = db_functions.collect_tables_tracking_status[:tracked]
64
+ puts "Will stop tracking #{tables.length} tables."
65
+ tables.each do |table_name|
66
+ db_functions.disable_tracking_for_table(table_name)
67
+ end
68
+
69
+ tables = db_functions.collect_tables_tracking_status[:tracked]
70
+ if tables.length > 0
71
+ puts "WARNING: Something went wrong. There are still #{tables.length}" + \
72
+ " tables being tracked."
73
+ else
74
+ puts "Done!"
75
+ end
67
76
  end
68
77
  end
69
78
 
70
79
  desc 'Shows which tables are tracking, missing and ignored.'
71
80
  task status: :environment do
72
- status = IronTrail::RakeHelper.db_functions.collect_tables_tracking_status
81
+ status = ActiveRecord::Base.with_connection do |conn|
82
+ IronTrail::RakeHelper.db_functions(conn).collect_tables_tracking_status
83
+ end
73
84
  ignored = (IronTrail.config.ignored_tables || [])
74
85
 
75
86
  # We likely want to keep this structure of text untouched as someone
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: iron_trail
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.0.pre.alpha2
4
+ version: 0.3.0.pre.alpha3
5
5
  platform: ruby
6
6
  authors:
7
7
  - André Diego Piske
@@ -159,7 +159,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
159
159
  requirements:
160
160
  - - ">="
161
161
  - !ruby/object:Gem::Version
162
- version: 3.4.0
162
+ version: 3.3.0
163
163
  required_rubygems_version: !ruby/object:Gem::Requirement
164
164
  requirements:
165
165
  - - ">="