active_record_extended 3.2.1 → 3.3.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: 2611c1b573495ab42f5a15ff8d85bdc8ba95bbe8d077ae037a5eae8e8f29f2c6
4
- data.tar.gz: 4d6c36a2e09b490969f8f152bda00a45180bbcd0a728fb7344e058faa96da10c
3
+ metadata.gz: 978b35d2ba33492c2de59e8d26fbc1f176ae1d8a19046a3e3276e693d3f6195f
4
+ data.tar.gz: 7a620d8e05d23252e4631c2a91f3bc62f8d983191631c2438ab98b5d0640e90a
5
5
  SHA512:
6
- metadata.gz: 8bbb84f095b990140d2cc7f6e11de1c7b11a039d4f6cdf02f910c470c9dd5cf71df71dcd344140e02baaec9969000c0d665845e830fff7aeddf3111339b578c2
7
- data.tar.gz: cc11bebd6832cdb82cacc31d5af01d8dc9123414ef5f2ed3c7c8e995a3e2005352444cd247c79de081f473d9c8fcde7758d7cbdfe156c2b909bcea2f78a24c6d
6
+ metadata.gz: 9c0f2ba4720495e95a53bf8971ce634af1d2eaf88af05faff5328bfcfadfb7f5da61c5e7984e46389b8b495cd5966fcedeaffac1317474042dd7bf67464c3408
7
+ data.tar.gz: 94ae654f051a427e745e8e761411df466cd4ed64b7a131d9326fa05d82e06f5ba0daa81dfa83f6a6be9ec252fa08d41d1559b87098616413606ea67444af1f38
data/README.md CHANGED
@@ -52,12 +52,12 @@ Active Record Extended is essentially providing users with the other half of Pos
52
52
  ## Compatibility
53
53
 
54
54
  This package is designed align and work with any officially supported Ruby and Rails versions.
55
- - Minimum Ruby Version: 2.7.x **(EOL warning!)**
56
- - Minimum Rails Version: 5.2.x **(EOL warning!)**
57
- - Minimum Postgres Version: 11.x **(EOL warning!)**
58
- - Latest Ruby supported: 3.2.x
59
- - Latest Rails supported: 7.0.x
60
- - Postgres: 11-current(15) (probably works with most older versions to a certain point)
55
+ - Minimum Ruby Version: 3.1.x **(EOL warning!)**
56
+ - Minimum Rails Version: 6.1.x **(EOL warning!)**
57
+ - Minimum Postgres Version: 12.x **(EOL warning!)**
58
+ - Latest Ruby supported: 3.3.x
59
+ - Latest Rails supported: 7.1.x
60
+ - Postgres: 11-current(16) (probably works with most older versions to a certain point)
61
61
 
62
62
  ## Installation
63
63
 
@@ -5,10 +5,6 @@ require "arel/nodes/function"
5
5
 
6
6
  module Arel
7
7
  module Nodes
8
- unless ActiveRecordExtended::AR_VERSION_GTE_6_1
9
- ["Contains", "Overlaps"].each { |binary_node_name| const_set(binary_node_name, Class.new(::Arel::Nodes::Binary)) }
10
- end
11
-
12
8
  [
13
9
  "ContainsHStore",
14
10
  "ContainsArray",
@@ -8,29 +8,6 @@ module ActiveRecordExtended
8
8
  private
9
9
 
10
10
  # rubocop:disable Naming/MethodName
11
-
12
- unless ActiveRecordExtended::AR_VERSION_GTE_6_1
13
- def visit_Arel_Nodes_Overlaps(object, collector)
14
- infix_value object, collector, " && "
15
- end
16
- end
17
-
18
- unless ActiveRecordExtended::AR_VERSION_GTE_6_1
19
- def visit_Arel_Nodes_Contains(object, collector)
20
- left_column = object.left.relation.name.classify.constantize.columns.detect do |col|
21
- matchable_column?(col, object)
22
- end
23
-
24
- if [:hstore, :jsonb].include?(left_column&.type)
25
- visit_Arel_Nodes_ContainsHStore(object, collector)
26
- elsif left_column.try(:array)
27
- visit_Arel_Nodes_ContainsArray(object, collector)
28
- else
29
- visit_Arel_Nodes_Inet_Contains(object, collector)
30
- end
31
- end
32
- end
33
-
34
11
  def visit_Arel_Nodes_ContainsArray(object, collector)
35
12
  infix_value object, collector, " @> "
36
13
  end
@@ -13,7 +13,7 @@ module ActiveRecordExtended
13
13
  return attribute.eq(value) if column.try(:array)
14
14
  end
15
15
 
16
- super(attribute, value)
16
+ super
17
17
  end
18
18
  end
19
19
  end
@@ -7,7 +7,7 @@ module ActiveRecordExtended
7
7
  include ActiveRecordExtended::Utilities::Support
8
8
  include ActiveRecordExtended::Utilities::OrderBy
9
9
 
10
- AGGREGATE_ONE_LINERS = /^(exists|sum|max|min|avg|count|jsonb?_agg|(bit|bool)_(and|or)|xmlagg|array_agg)$/.freeze
10
+ AGGREGATE_ONE_LINERS = /^(exists|sum|max|min|avg|count|jsonb?_agg|(bit|bool)_(and|or)|xmlagg|array_agg)$/
11
11
 
12
12
  def initialize(scope)
13
13
  @scope = scope
@@ -92,16 +92,16 @@ module ActiveRecordExtended
92
92
  unionized_name: lambda { |klass| klass.arel_table.name }
93
93
  }.each_pair do |method_name, default|
94
94
  define_method(method_name) do
95
- return unionize_storage[method_name] if send("#{method_name}?")
95
+ return unionize_storage[method_name] if send(:"#{method_name}?")
96
96
 
97
97
  (default.is_a?(Proc) ? default.call(@klass) : default.new)
98
98
  end
99
99
 
100
- define_method("#{method_name}?") do
100
+ define_method(:"#{method_name}?") do
101
101
  unionize_storage.key?(method_name) && !unionize_storage[method_name].presence.nil?
102
102
  end
103
103
 
104
- define_method("#{method_name}=") do |value|
104
+ define_method(:"#{method_name}=") do |value|
105
105
  unionize_storage![method_name] = value
106
106
  end
107
107
  end
@@ -46,26 +46,7 @@ module ActiveRecordExtended
46
46
  # # SELECT tags.* FROM tags INNER JOIN user on user.id = tags.user_id WHERE user.data @> { nickname: 'chainer' }
47
47
  #
48
48
  def contains(opts, *rest)
49
- if ActiveRecordExtended::AR_VERSION_GTE_6_1
50
- return substitute_comparisons(opts, rest, Arel::Nodes::Contains, "contains")
51
- end
52
-
53
- build_where_chain(opts, rest) do |arel|
54
- case arel
55
- when Arel::Nodes::In, Arel::Nodes::Equality
56
- column = left_column(arel) || column_from_association(arel)
57
-
58
- if [:hstore, :jsonb].include?(column.type)
59
- Arel::Nodes::ContainsHStore.new(arel.left, arel.right)
60
- elsif column.try(:array)
61
- Arel::Nodes::ContainsArray.new(arel.left, arel.right)
62
- else
63
- raise ArgumentError.new("Invalid argument for .where.contains(), got #{arel.class}")
64
- end
65
- else
66
- raise ArgumentError.new("Invalid argument for .where.contains(), got #{arel.class}")
67
- end
68
- end
49
+ substitute_comparisons(opts, rest, Arel::Nodes::Contains, "contains")
69
50
  end
70
51
 
71
52
  private
@@ -111,11 +92,7 @@ module ActiveRecordExtended
111
92
  end
112
93
 
113
94
  def build_where_clause_for(scope, opts, rest)
114
- if ActiveRecordExtended::AR_VERSION_GTE_6_1
115
- scope.send(:build_where_clause, opts, rest)
116
- else
117
- scope.send(:where_clause_factory).build(opts, rest)
118
- end
95
+ scope.send(:build_where_clause, opts, rest)
119
96
  end
120
97
  end
121
98
  end
@@ -44,7 +44,7 @@ module ActiveRecordExtended
44
44
  end
45
45
 
46
46
  # @param [Hash, WithCTE] value
47
- def pipe_cte_with!(value)
47
+ def pipe_cte_with!(value) # rubocop:disable Metrics/AbcSize, Metrics/PerceivedComplexity
48
48
  return if value.nil? || value.empty?
49
49
 
50
50
  value.each_pair do |name, expression|
@@ -54,6 +54,8 @@ module ActiveRecordExtended
54
54
  # Ensure we follow FIFO pattern.
55
55
  # If the parent has similar CTE alias keys, we want to favor the parent's expressions over its children's.
56
56
  if expression.is_a?(ActiveRecord::Relation) && expression.with_values?
57
+ expression.cte = expression.cte.dup if expression.cte
58
+
57
59
  # Add child's materialized keys to the parent
58
60
  @materialized_keys += expression.cte.materialized_keys
59
61
  @not_materialized_keys += expression.cte.not_materialized_keys
@@ -136,6 +138,11 @@ module ActiveRecordExtended
136
138
  !(cte.nil? || cte.empty?)
137
139
  end
138
140
 
141
+ # @return [Array<Hash>]
142
+ def with_values
143
+ with_values? ? [cte.with_values] : []
144
+ end
145
+
139
146
  # @param [Hash, WithCTE] values
140
147
  def with_values=(values)
141
148
  cte.with_values = values
@@ -2,7 +2,7 @@
2
2
 
3
3
  module ActiveRecordExtended
4
4
  module Utilities
5
- module Support
5
+ module Support # rubocop:disable Metrics/ModuleLength
6
6
  A_TO_Z_KEYS = ("a".."z").to_a.freeze
7
7
 
8
8
  # We need to ensure we can flatten nested ActiveRecord::Relations
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module ActiveRecordExtended
4
- VERSION = "3.2.1"
4
+ VERSION = "3.3.0"
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: active_record_extended
3
3
  version: !ruby/object:Gem::Version
4
- version: 3.2.1
4
+ version: 3.3.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - George Protacio-Karaszi
@@ -10,7 +10,7 @@ authors:
10
10
  autorequire:
11
11
  bindir: bin
12
12
  cert_chain: []
13
- date: 2023-02-17 00:00:00.000000000 Z
13
+ date: 2024-07-22 00:00:00.000000000 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: activerecord
@@ -21,7 +21,7 @@ dependencies:
21
21
  version: '5.2'
22
22
  - - "<"
23
23
  - !ruby/object:Gem::Version
24
- version: 7.2.0
24
+ version: 8.0.0
25
25
  type: :runtime
26
26
  prerelease: false
27
27
  version_requirements: !ruby/object:Gem::Requirement
@@ -31,7 +31,7 @@ dependencies:
31
31
  version: '5.2'
32
32
  - - "<"
33
33
  - !ruby/object:Gem::Version
34
- version: 7.2.0
34
+ version: 8.0.0
35
35
  - !ruby/object:Gem::Dependency
36
36
  name: pg
37
37
  requirement: !ruby/object:Gem::Requirement
@@ -46,96 +46,6 @@ dependencies:
46
46
  - - "<"
47
47
  - !ruby/object:Gem::Version
48
48
  version: '3.0'
49
- - !ruby/object:Gem::Dependency
50
- name: bundler
51
- requirement: !ruby/object:Gem::Requirement
52
- requirements:
53
- - - ">="
54
- - !ruby/object:Gem::Version
55
- version: '2.2'
56
- - - "<"
57
- - !ruby/object:Gem::Version
58
- version: '3.0'
59
- type: :development
60
- prerelease: false
61
- version_requirements: !ruby/object:Gem::Requirement
62
- requirements:
63
- - - ">="
64
- - !ruby/object:Gem::Version
65
- version: '2.2'
66
- - - "<"
67
- - !ruby/object:Gem::Version
68
- version: '3.0'
69
- - !ruby/object:Gem::Dependency
70
- name: database_cleaner
71
- requirement: !ruby/object:Gem::Requirement
72
- requirements:
73
- - - "~>"
74
- - !ruby/object:Gem::Version
75
- version: '2.0'
76
- type: :development
77
- prerelease: false
78
- version_requirements: !ruby/object:Gem::Requirement
79
- requirements:
80
- - - "~>"
81
- - !ruby/object:Gem::Version
82
- version: '2.0'
83
- - !ruby/object:Gem::Dependency
84
- name: rake
85
- requirement: !ruby/object:Gem::Requirement
86
- requirements:
87
- - - ">="
88
- - !ruby/object:Gem::Version
89
- version: '10.0'
90
- type: :development
91
- prerelease: false
92
- version_requirements: !ruby/object:Gem::Requirement
93
- requirements:
94
- - - ">="
95
- - !ruby/object:Gem::Version
96
- version: '10.0'
97
- - !ruby/object:Gem::Dependency
98
- name: rspec
99
- requirement: !ruby/object:Gem::Requirement
100
- requirements:
101
- - - "~>"
102
- - !ruby/object:Gem::Version
103
- version: '3.0'
104
- type: :development
105
- prerelease: false
106
- version_requirements: !ruby/object:Gem::Requirement
107
- requirements:
108
- - - "~>"
109
- - !ruby/object:Gem::Version
110
- version: '3.0'
111
- - !ruby/object:Gem::Dependency
112
- name: rspec-sqlimit
113
- requirement: !ruby/object:Gem::Requirement
114
- requirements:
115
- - - "~>"
116
- - !ruby/object:Gem::Version
117
- version: 0.0.5
118
- type: :development
119
- prerelease: false
120
- version_requirements: !ruby/object:Gem::Requirement
121
- requirements:
122
- - - "~>"
123
- - !ruby/object:Gem::Version
124
- version: 0.0.5
125
- - !ruby/object:Gem::Dependency
126
- name: simplecov
127
- requirement: !ruby/object:Gem::Requirement
128
- requirements:
129
- - - "~>"
130
- - !ruby/object:Gem::Version
131
- version: '0.16'
132
- type: :development
133
- prerelease: false
134
- version_requirements: !ruby/object:Gem::Requirement
135
- requirements:
136
- - - "~>"
137
- - !ruby/object:Gem::Version
138
- version: '0.16'
139
49
  description: Adds extended functionality to Activerecord Postgres implementation
140
50
  email:
141
51
  - georgekaraszi@gmail.com
@@ -181,14 +91,14 @@ required_ruby_version: !ruby/object:Gem::Requirement
181
91
  requirements:
182
92
  - - ">="
183
93
  - !ruby/object:Gem::Version
184
- version: '2.7'
94
+ version: '3.1'
185
95
  required_rubygems_version: !ruby/object:Gem::Requirement
186
96
  requirements:
187
97
  - - ">="
188
98
  - !ruby/object:Gem::Version
189
99
  version: '0'
190
100
  requirements: []
191
- rubygems_version: 3.4.1
101
+ rubygems_version: 3.5.11
192
102
  signing_key:
193
103
  specification_version: 4
194
104
  summary: Adds extended functionality to Activerecord Postgres implementation