activerecord-cte 0.2.0 → 0.4.0

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: 24b0c6a6425bfa8f8b7137d7f3a96b84aa97c10f4d00b25c5a091890fef2de73
4
- data.tar.gz: d6856b61cf2e747807af2baf843a41c3e667832a97183ff3db3867486c8e9d90
3
+ metadata.gz: 7ee8e61752f68bb7edd5f18be270ce354bf08f881ee779f023c022735625f82b
4
+ data.tar.gz: 7a4a6adc9e75bc155c8e0b1c17a2726271c8c719dc27016802731cb1156571ab
5
5
  SHA512:
6
- metadata.gz: 0c68905f134a9d8c4e52a21aa1ab278b4de60b00fc93d2acd6935f0a65d8699fa76f543e03f6d9885d1fb148bdd48f9d072d9c66a12d7cb988e158068cb678ed
7
- data.tar.gz: 0c999b62136a17857046eeb384a9fc8090e9cf70d8e7fa06febdd663169994ce348c657cc414795e5f47fc73fb7325d6903e3f5ed202c124d2d832b8bed45b70
6
+ metadata.gz: bf8bbe920da9765dc097a627b67b58039ff0c6a8de422d90a1dc98cd19d9c609b9f9f54fb1df34dbffa31f5c0541254d8dd023ca96d732772c690a9043893e4a
7
+ data.tar.gz: 0ecd47849d448e25af91feb1a5ea340977b1f479acfd428f1072c2d24b1c73991b259f6a31076faaed86921d5434989a7e59764fcd79d7ac6a8ddf49ac595213
@@ -6,7 +6,15 @@ jobs:
6
6
  strategy:
7
7
  fail-fast: false
8
8
  matrix:
9
- active_record: [6.1.4, 6.0.4]
9
+ active_record: [6.1.7.2, 6.0.6, 5.2.8.1]
10
+ ruby: ['3.0', 3.1, 3.2]
11
+ exclude:
12
+ - active_record: 5.2.8.1
13
+ ruby: '3.0'
14
+ - active_record: 5.2.8.1
15
+ ruby: 3.1
16
+ - active_record: 5.2.8.1
17
+ ruby: 3.2
10
18
  env:
11
19
  ACTIVE_RECORD_VERSION: ${{ matrix.active_record }}
12
20
  DATABASE_ADAPTER: mysql
@@ -20,6 +28,7 @@ jobs:
20
28
  - name: Set up Ruby
21
29
  uses: ruby/setup-ruby@v1
22
30
  with:
31
+ ruby-version: ${{ matrix.ruby }}
23
32
  bundler-cache: true # runs 'bundle install' and caches installed gems automatically
24
33
  - name: Run tests
25
34
  run: bundle exec rake test
@@ -3,11 +3,19 @@ on: [pull_request]
3
3
  jobs:
4
4
  Test-With-PostgreSQL:
5
5
  runs-on: ubuntu-latest
6
- container: ruby:3.0
6
+ container: ruby:${{ matrix.ruby }}
7
7
  strategy:
8
8
  fail-fast: false
9
9
  matrix:
10
- active_record: [6.1.4, 6.0.4]
10
+ active_record: [6.1.7.2, 6.0.6, 5.2.8.1]
11
+ ruby: ['3.0', 3.1, 3.2]
12
+ exclude:
13
+ - active_record: 5.2.8.1
14
+ ruby: '3.0'
15
+ - active_record: 5.2.8.1
16
+ ruby: 3.1
17
+ - active_record: 5.2.8.1
18
+ ruby: 3.2
11
19
  env:
12
20
  ACTIVE_RECORD_VERSION: ${{ matrix.active_record }}
13
21
  DATABASE_ADAPTER: postgresql
@@ -28,6 +36,8 @@ jobs:
28
36
  steps:
29
37
  - name: Check out repository code
30
38
  uses: actions/checkout@v2
39
+ - name: Update bundler
40
+ run: gem update bundler # Use the latest bundler
31
41
  - name: Bundle dependencies
32
42
  run: bundle install
33
43
  - name: Run tests
@@ -6,12 +6,16 @@ jobs:
6
6
  strategy:
7
7
  fail-fast: false
8
8
  matrix:
9
- active_record: [6.1.4, 6.0.4, 5.2.6]
9
+ active_record: [6.1.7.2, 6.0.6, 5.2.8.1]
10
10
  # Due to https://github.com/actions/runner/issues/849, we have to use quotes for '3.0'
11
- ruby: [2.6, 2.7, '3.0']
11
+ ruby: ['3.0', 3.1, 3.2]
12
12
  exclude:
13
- - active_record: 5.2.6
13
+ - active_record: 5.2.8.1
14
14
  ruby: '3.0'
15
+ - active_record: 5.2.8.1
16
+ ruby: 3.1
17
+ - active_record: 5.2.8.1
18
+ ruby: 3.2
15
19
 
16
20
  env:
17
21
  ACTIVE_RECORD_VERSION: ${{ matrix.active_record }}
data/.ruby-version CHANGED
@@ -1 +1 @@
1
- 3.0.2
1
+ 3.1.2
data/Dockerfile CHANGED
@@ -1,4 +1,4 @@
1
- FROM ruby:3.0
1
+ FROM ruby:3.1
2
2
 
3
3
  ENV APP_HOME /activerecord_cte
4
4
  RUN mkdir $APP_HOME
data/Gemfile CHANGED
@@ -5,11 +5,11 @@ source "https://rubygems.org"
5
5
  # Specify your gem's dependencies in activerecord-cte.gemspec
6
6
  gemspec
7
7
 
8
- ACTIVE_RECORD_VERSION = ENV.fetch("ACTIVE_RECORD_VERSION", "6.1.4")
8
+ ACTIVE_RECORD_VERSION = ENV.fetch("ACTIVE_RECORD_VERSION", "6.1.7.2")
9
9
 
10
10
  gem "activerecord", ACTIVE_RECORD_VERSION
11
11
 
12
12
  gem "mysql2" if ENV["INSTALL_MYSQL_GEM"]
13
13
  gem "pg" if ENV["INSTALL_PG_GEM"]
14
14
 
15
- gem "sqlite3", "1.4.2"
15
+ gem "sqlite3", "1.7.3"
data/bin/test CHANGED
@@ -4,7 +4,7 @@
4
4
  require "English"
5
5
  require "yaml"
6
6
 
7
- active_record_versions = %w[6.1.4 6.0.4]
7
+ active_record_versions = %w[6.1.7.2 6.0.6]
8
8
  database_adapters = %w[mysql postgresql sqlite3]
9
9
 
10
10
  class Matrix
@@ -15,6 +15,7 @@ module ActiveRecord
15
15
  private
16
16
 
17
17
  def merge_withs
18
+ relation.recursive_with = true if other.recursive_with?
18
19
  other_values = other.with_values.reject { |value| relation.with_values.include?(value) }
19
20
  relation.with!(*other_values) if other_values.any?
20
21
  end
@@ -30,7 +31,12 @@ module ActiveRecord
30
31
  end
31
32
 
32
33
  def with!(opts, *rest)
33
- self.with_values += [opts] + rest
34
+ if opts == :recursive
35
+ self.recursive_with = true
36
+ self.with_values += rest
37
+ else
38
+ self.with_values += [opts] + rest
39
+ end
34
40
  self
35
41
  end
36
42
 
@@ -44,6 +50,16 @@ module ActiveRecord
44
50
  @values[:with] = values
45
51
  end
46
52
 
53
+ def recursive_with?
54
+ @values[:recursive_with]
55
+ end
56
+
57
+ def recursive_with=(value)
58
+ raise ImmutableRelation if @loaded
59
+
60
+ @values[:recursive_with] = value
61
+ end
62
+
47
63
  private
48
64
 
49
65
  def build_arel(*args)
@@ -55,7 +71,6 @@ module ActiveRecord
55
71
  def build_with(arel) # rubocop:disable Metrics/MethodLength, Metrics/CyclomaticComplexity
56
72
  return if with_values.empty?
57
73
 
58
- recursive = with_values.delete(:recursive)
59
74
  with_statements = with_values.map do |with_value|
60
75
  case with_value
61
76
  when String then Arel::Nodes::SqlLiteral.new(with_value)
@@ -67,7 +82,7 @@ module ActiveRecord
67
82
  end
68
83
  end
69
84
 
70
- recursive ? arel.with(:recursive, with_statements) : arel.with(with_statements)
85
+ recursive_with? ? arel.with(:recursive, with_statements) : arel.with(with_statements)
71
86
  end
72
87
 
73
88
  def build_with_value_from_array(array)
@@ -84,7 +99,7 @@ module ActiveRecord
84
99
  expression = case value
85
100
  when String then Arel::Nodes::SqlLiteral.new("(#{value})")
86
101
  when ActiveRecord::Relation then value.arel
87
- when Arel::SelectManager, Arel::Nodes::Union then value
102
+ when Arel::SelectManager, Arel::Nodes::Union, Arel::Nodes::UnionAll then value
88
103
  else
89
104
  raise ArgumentError, "Unsupported argument type: #{value} #{value.class}"
90
105
  end
@@ -2,6 +2,6 @@
2
2
 
3
3
  module Activerecord
4
4
  module Cte
5
- VERSION = "0.2.0"
5
+ VERSION = "0.4.0"
6
6
  end
7
7
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: activerecord-cte
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.0
4
+ version: 0.4.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Vlado Cingel
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2021-07-25 00:00:00.000000000 Z
11
+ date: 2024-09-13 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activerecord
@@ -189,7 +189,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
189
189
  - !ruby/object:Gem::Version
190
190
  version: '0'
191
191
  requirements: []
192
- rubygems_version: 3.2.22
192
+ rubygems_version: 3.3.7
193
193
  signing_key:
194
194
  specification_version: 4
195
195
  summary: Brings Common Table Expressions support to ActiveRecord and makes it super