yiffspace-arel 0.0.1

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.
Files changed (28) hide show
  1. checksums.yaml +7 -0
  2. data/CHANGELOG.md +5 -0
  3. data/LICENSE +20 -0
  4. data/README.md +38 -0
  5. data/Rakefile +3 -0
  6. data/lib/yiffspace/arel/version.rb +7 -0
  7. data/lib/yiffspace/arel.rb +13 -0
  8. data/lib/yiffspace/core_ext/active_record/all.rb +7 -0
  9. data/lib/yiffspace/core_ext/active_record/cross_join_lateral.rb +7 -0
  10. data/lib/yiffspace/core_ext/active_record/cross_unnest.rb +7 -0
  11. data/lib/yiffspace/core_ext/active_record/left_join_lateral.rb +7 -0
  12. data/lib/yiffspace/core_ext/active_record/left_unnest.rb +7 -0
  13. data/lib/yiffspace/core_ext/active_record/unnest.rb +8 -0
  14. data/lib/yiffspace/core_ext/arel/all.rb +4 -0
  15. data/lib/yiffspace/core_ext/arel/cross_join_lateral.rb +21 -0
  16. data/lib/yiffspace/core_ext/arel/left_join_lateral.rb +21 -0
  17. data/lib/yiffspace/extensions/active_record/cross_join_lateral.rb +23 -0
  18. data/lib/yiffspace/extensions/active_record/cross_unnest.rb +15 -0
  19. data/lib/yiffspace/extensions/active_record/left_join_lateral.rb +24 -0
  20. data/lib/yiffspace/extensions/active_record/left_unnest.rb +15 -0
  21. data/lib/yiffspace/extensions/active_record/unnest.rb +20 -0
  22. data/lib/yiffspace/extensions/arel/nodes/cross_join_lateral.rb +17 -0
  23. data/lib/yiffspace/extensions/arel/nodes/left_join_lateral.rb +17 -0
  24. data/lib/yiffspace/extensions/arel/table/cross_join_lateral.rb +15 -0
  25. data/lib/yiffspace/extensions/arel/table/left_join_lateral.rb +15 -0
  26. data/lib/yiffspace/extensions/arel/visitors/postgresql/cross_join_lateral.rb +19 -0
  27. data/lib/yiffspace/extensions/arel/visitors/postgresql/left_join_lateral.rb +23 -0
  28. metadata +101 -0
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: 16066f1acde1ce2560d9957292423d90f5cfdc7a43acc694d59aaae0fa32fa68
4
+ data.tar.gz: b5437db5c64f23237b9724ef001775ed66f1ff125b78081c5fb3be9425318910
5
+ SHA512:
6
+ metadata.gz: 80e0c8b8c9d8a949927261258344ce20109a76c6d266fddabdce1f12be7d0e3c9958c8cd975b1b1f0eeef72b2f8274ff5773a9236ac7651d4703a21e779744fd
7
+ data.tar.gz: 6ab2c75ed8af7f6931b1566e651c222ae7133d5770bf7a5c45c7a1fabfc57a62396c2ea112867f4e1caa34cc28ad816ed293ac0598c5c1504b11025eb24a3769
data/CHANGELOG.md ADDED
@@ -0,0 +1,5 @@
1
+ ## 0.0.1
2
+
3
+ - Initial release, extracted from the `yiffspace` gem's
4
+ `YiffSpace::Extensions::ActiveRecord`/`YiffSpace::Extensions::Arel`
5
+ lateral-join/unnest extensions and their `core_ext` global aliases.
data/LICENSE ADDED
@@ -0,0 +1,20 @@
1
+ Copyright Donovan_DMC
2
+
3
+ Permission is hereby granted, free of charge, to any person obtaining
4
+ a copy of this software and associated documentation files (the
5
+ "Software"), to deal in the Software without restriction, including
6
+ without limitation the rights to use, copy, modify, merge, publish,
7
+ distribute, sublicense, and/or sell copies of the Software, and to
8
+ permit persons to whom the Software is furnished to do so, subject to
9
+ the following conditions:
10
+
11
+ The above copyright notice and this permission notice shall be
12
+ included in all copies or substantial portions of the Software.
13
+
14
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
15
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
16
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
17
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
18
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
19
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
20
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,38 @@
1
+ # YiffSpace::Arel
2
+
3
+ Postgres lateral-join/unnest ActiveRecord & Arel extensions
4
+ (`cross_join_lateral`, `left_join_lateral`, `unnest`, `cross_unnest`,
5
+ `left_unnest`), for https://yiff.space and related projects. No dependency
6
+ on `yiffspace` itself - pure additive ActiveRecord/Arel monkeypatches.
7
+
8
+ ## Installation
9
+
10
+ Add this line to your application's Gemfile:
11
+
12
+ ```ruby
13
+ gem "yiffspace-arel"
14
+ ```
15
+
16
+ And then execute:
17
+
18
+ ```bash
19
+ $ bundle install
20
+ ```
21
+
22
+ ## Usage
23
+
24
+ ```ruby
25
+ Post.joins_lateral_unnest # etc - see YiffSpace::Extensions::ActiveRecord::*
26
+ ```
27
+
28
+ The old global monkeypatch style (`core_ext/**`) is still available via
29
+ `require("yiffspace/core_ext/active_record/all")`, aliasing the same
30
+ behavior onto `ActiveRecord::Relation`/`Arel` directly.
31
+
32
+ ## Contributing
33
+
34
+ Go away
35
+
36
+ ## License
37
+
38
+ The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
data/Rakefile ADDED
@@ -0,0 +1,3 @@
1
+ # frozen_string_literal: true
2
+
3
+ require("bundler/gem_tasks")
@@ -0,0 +1,7 @@
1
+ # frozen_string_literal: true
2
+
3
+ module YiffSpace
4
+ module Arel
5
+ VERSION = "0.0.1"
6
+ end
7
+ end
@@ -0,0 +1,13 @@
1
+ # frozen_string_literal: true
2
+
3
+ require("zeitwerk")
4
+
5
+ module YiffSpace
6
+ module Arel
7
+ end
8
+ end
9
+
10
+ loader = Zeitwerk::Loader.for_gem_extension(YiffSpace)
11
+ loader.inflector.inflect({ "postgresql" => "PostgreSQL" })
12
+ loader.ignore("#{__dir__}/core_ext")
13
+ loader.setup
@@ -0,0 +1,7 @@
1
+ # frozen_string_literal: true
2
+
3
+ require_relative("cross_join_lateral")
4
+ require_relative("cross_unnest")
5
+ require_relative("left_join_lateral")
6
+ require_relative("left_unnest")
7
+ require_relative("unnest")
@@ -0,0 +1,7 @@
1
+ # frozen_string_literal: true
2
+
3
+ require("active_record/relation")
4
+ require_relative("../arel/cross_join_lateral")
5
+ require_relative("../../extensions/active_record/cross_join_lateral")
6
+
7
+ ActiveRecord::Relation.include(YiffSpace::Extensions::ActiveRecord::CrossJoinLateral)
@@ -0,0 +1,7 @@
1
+ # frozen_string_literal: true
2
+
3
+ require("active_record/relation")
4
+ require_relative("unnest")
5
+ require_relative("../../extensions/active_record/cross_unnest")
6
+
7
+ ActiveRecord::Relation.include(YiffSpace::Extensions::ActiveRecord::CrossUnnest)
@@ -0,0 +1,7 @@
1
+ # frozen_string_literal: true
2
+
3
+ require("active_record/relation")
4
+ require_relative("../arel/left_join_lateral")
5
+ require_relative("../../extensions/active_record/left_join_lateral")
6
+
7
+ ActiveRecord::Relation.include(YiffSpace::Extensions::ActiveRecord::LeftJoinLateral)
@@ -0,0 +1,7 @@
1
+ # frozen_string_literal: true
2
+
3
+ require("active_record/relation")
4
+ require_relative("unnest")
5
+ require_relative("../../extensions/active_record/left_unnest")
6
+
7
+ ActiveRecord::Relation.include(YiffSpace::Extensions::ActiveRecord::LeftUnnest)
@@ -0,0 +1,8 @@
1
+ # frozen_string_literal: true
2
+
3
+ require("active_record/relation")
4
+ require_relative("cross_join_lateral")
5
+ require_relative("left_join_lateral")
6
+ require_relative("../../extensions/active_record/unnest")
7
+
8
+ ActiveRecord::Relation.include(YiffSpace::Extensions::ActiveRecord::Unnest)
@@ -0,0 +1,4 @@
1
+ # frozen_string_literal: true
2
+
3
+ require_relative("cross_join_lateral")
4
+ require_relative("left_join_lateral")
@@ -0,0 +1,21 @@
1
+ # frozen_string_literal: true
2
+
3
+ require_relative("../../extensions/arel/nodes/cross_join_lateral")
4
+ require_relative("../../extensions/arel/visitors/postgresql/cross_join_lateral")
5
+ require_relative("../../extensions/arel/table/cross_join_lateral")
6
+
7
+ module Arel
8
+ module Nodes
9
+ CrossJoinLateral = YiffSpace::Extensions::Arel::Nodes::CrossJoinLateral
10
+ end
11
+
12
+ module Visitors
13
+ class PostgreSQL
14
+ include(YiffSpace::Extensions::Arel::Visitors::PostgreSQL::CrossJoinLateral)
15
+ end
16
+ end
17
+
18
+ class Table
19
+ include(YiffSpace::Extensions::Arel::Table::CrossJoinLateral)
20
+ end
21
+ end
@@ -0,0 +1,21 @@
1
+ # frozen_string_literal: true
2
+
3
+ require_relative("../../extensions/arel/nodes/left_join_lateral")
4
+ require_relative("../../extensions/arel/visitors/postgresql/left_join_lateral")
5
+ require_relative("../../extensions/arel/table/left_join_lateral")
6
+
7
+ module Arel
8
+ module Nodes
9
+ LeftJoinLateral = YiffSpace::Extensions::Arel::Nodes::LeftJoinLateral
10
+ end
11
+
12
+ module Visitors
13
+ class PostgreSQL
14
+ include(YiffSpace::Extensions::Arel::Visitors::PostgreSQL::LeftJoinLateral)
15
+ end
16
+ end
17
+
18
+ class Table
19
+ include(YiffSpace::Extensions::Arel::Table::LeftJoinLateral)
20
+ end
21
+ end
@@ -0,0 +1,23 @@
1
+ # frozen_string_literal: true
2
+
3
+ module YiffSpace
4
+ module Extensions
5
+ module ActiveRecord
6
+ module CrossJoinLateral
7
+ def cross_join_lateral(relation)
8
+ raise(ArgumentError, "The method .cross_join_lateral() must contain arguments.") if relation.nil?
9
+
10
+ relation = relation.arel if relation.respond_to?(:arel)
11
+ spawn.cross_join_lateral!(relation)
12
+ end
13
+
14
+ def cross_join_lateral!(relation) # :nodoc:
15
+ manager = klass.arel_table.cross_join_lateral(relation)
16
+
17
+ self.joins_values |= [manager.join_sources.first]
18
+ self
19
+ end
20
+ end
21
+ end
22
+ end
23
+ end
@@ -0,0 +1,15 @@
1
+ # frozen_string_literal: true
2
+
3
+ module YiffSpace
4
+ module Extensions
5
+ module ActiveRecord
6
+ module CrossUnnest
7
+ def cross_unnest(column, as: column.singularize)
8
+ raise(ArgumentError, "The method .cross_unnest() must contain arguments.") if column.nil?
9
+
10
+ spawn.unnest(column, as: as, type: :cross_join_lateral)
11
+ end
12
+ end
13
+ end
14
+ end
15
+ end
@@ -0,0 +1,24 @@
1
+ # frozen_string_literal: true
2
+
3
+ module YiffSpace
4
+ module Extensions
5
+ module ActiveRecord
6
+ module LeftJoinLateral
7
+ def left_join_lateral(relation, on: nil)
8
+ raise(ArgumentError, "The method .left_join_lateral() must contain arguments.") if relation.nil?
9
+
10
+ relation = relation.arel if relation.respond_to?(:arel)
11
+ spawn.left_join_lateral!(relation, on: on)
12
+ end
13
+
14
+ def left_join_lateral!(relation, on: nil) # :nodoc:
15
+ manager = klass.arel_table.left_join_lateral(relation)
16
+ manager.on(on) if on
17
+
18
+ self.joins_values |= [manager.join_sources.first]
19
+ self
20
+ end
21
+ end
22
+ end
23
+ end
24
+ end
@@ -0,0 +1,15 @@
1
+ # frozen_string_literal: true
2
+
3
+ module YiffSpace
4
+ module Extensions
5
+ module ActiveRecord
6
+ module LeftUnnest
7
+ def left_unnest(column, as: column.singularize)
8
+ raise(ArgumentError, "The method .left_unnest() must contain arguments.") if column.nil?
9
+
10
+ spawn.unnest(column, as: as, type: :left_join_lateral)
11
+ end
12
+ end
13
+ end
14
+ end
15
+ end
@@ -0,0 +1,20 @@
1
+ # frozen_string_literal: true
2
+
3
+ module YiffSpace
4
+ module Extensions
5
+ module ActiveRecord
6
+ module Unnest
7
+ def unnest(column, as: column.singularize, type: :left_join_lateral)
8
+ raise(ArgumentError, "The method .unnest() must contain arguments.") if column.nil?
9
+
10
+ spawn.unnest!(column, as, type)
11
+ end
12
+
13
+ def unnest!(column, name, type) # :nodoc:
14
+ function = ::Arel::Nodes::NamedFunction.new("unnest", [klass.arel_table[column]]).as(name)
15
+ spawn.send("#{type}!", function, **({ on: ::Arel.sql("TRUE") } if type == :left_join_lateral))
16
+ end
17
+ end
18
+ end
19
+ end
20
+ end
@@ -0,0 +1,17 @@
1
+ # frozen_string_literal: true
2
+
3
+ require("arel")
4
+
5
+ module YiffSpace
6
+ module Extensions
7
+ module Arel
8
+ module Nodes
9
+ class CrossJoinLateral < ::Arel::Nodes::Join
10
+ def initialize(left, right = nil)
11
+ super
12
+ end
13
+ end
14
+ end
15
+ end
16
+ end
17
+ end
@@ -0,0 +1,17 @@
1
+ # frozen_string_literal: true
2
+
3
+ require("arel")
4
+
5
+ module YiffSpace
6
+ module Extensions
7
+ module Arel
8
+ module Nodes
9
+ class LeftJoinLateral < ::Arel::Nodes::Join
10
+ def initialize(left, right = nil)
11
+ super
12
+ end
13
+ end
14
+ end
15
+ end
16
+ end
17
+ end
@@ -0,0 +1,15 @@
1
+ # frozen_string_literal: true
2
+
3
+ module YiffSpace
4
+ module Extensions
5
+ module Arel
6
+ module Table
7
+ module CrossJoinLateral
8
+ def cross_join_lateral(relation)
9
+ join(relation, ::Arel::Nodes::CrossJoinLateral)
10
+ end
11
+ end
12
+ end
13
+ end
14
+ end
15
+ end
@@ -0,0 +1,15 @@
1
+ # frozen_string_literal: true
2
+
3
+ module YiffSpace
4
+ module Extensions
5
+ module Arel
6
+ module Table
7
+ module LeftJoinLateral
8
+ def left_join_lateral(relation)
9
+ join(relation, ::Arel::Nodes::LeftJoinLateral)
10
+ end
11
+ end
12
+ end
13
+ end
14
+ end
15
+ end
@@ -0,0 +1,19 @@
1
+ # frozen_string_literal: true
2
+
3
+ module YiffSpace
4
+ module Extensions
5
+ module Arel
6
+ module Visitors
7
+ module PostgreSQL
8
+ module CrossJoinLateral
9
+ # noinspection RubyInstanceMethodNamingConvention
10
+ def visit_YiffSpace_Extensions_Arel_Nodes_CrossJoinLateral(o, collector)
11
+ collector << "CROSS JOIN LATERAL "
12
+ visit(o.left, collector)
13
+ end
14
+ end
15
+ end
16
+ end
17
+ end
18
+ end
19
+ end
@@ -0,0 +1,23 @@
1
+ # frozen_string_literal: true
2
+
3
+ module YiffSpace
4
+ module Extensions
5
+ module Arel
6
+ module Visitors
7
+ module PostgreSQL
8
+ module LeftJoinLateral
9
+ # noinspection RubyInstanceMethodNamingConvention
10
+ def visit_YiffSpace_Extensions_Arel_Nodes_LeftJoinLateral(o, collector)
11
+ collector << "LEFT JOIN LATERAL "
12
+ visit(o.left, collector)
13
+ return unless o.right
14
+
15
+ collector << " ON "
16
+ visit(o.right.expr, collector)
17
+ end
18
+ end
19
+ end
20
+ end
21
+ end
22
+ end
23
+ end
metadata ADDED
@@ -0,0 +1,101 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: yiffspace-arel
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ platform: ruby
6
+ authors:
7
+ - Donovan_DMC
8
+ bindir: bin
9
+ cert_chain: []
10
+ date: 2026-09-04 00:00:00.000000000 Z
11
+ dependencies:
12
+ - !ruby/object:Gem::Dependency
13
+ name: activerecord
14
+ requirement: !ruby/object:Gem::Requirement
15
+ requirements:
16
+ - - ">="
17
+ - !ruby/object:Gem::Version
18
+ version: '7.1'
19
+ type: :runtime
20
+ prerelease: false
21
+ version_requirements: !ruby/object:Gem::Requirement
22
+ requirements:
23
+ - - ">="
24
+ - !ruby/object:Gem::Version
25
+ version: '7.1'
26
+ - !ruby/object:Gem::Dependency
27
+ name: zeitwerk
28
+ requirement: !ruby/object:Gem::Requirement
29
+ requirements:
30
+ - - ">="
31
+ - !ruby/object:Gem::Version
32
+ version: '2.6'
33
+ type: :runtime
34
+ prerelease: false
35
+ version_requirements: !ruby/object:Gem::Requirement
36
+ requirements:
37
+ - - ">="
38
+ - !ruby/object:Gem::Version
39
+ version: '2.6'
40
+ description: Postgres lateral-join/unnest ActiveRecord & Arel extensions, for https://yiff.space
41
+ and related projects
42
+ email:
43
+ - hewwo@yiff.rocks
44
+ executables: []
45
+ extensions: []
46
+ extra_rdoc_files: []
47
+ files:
48
+ - CHANGELOG.md
49
+ - LICENSE
50
+ - README.md
51
+ - Rakefile
52
+ - lib/yiffspace/arel.rb
53
+ - lib/yiffspace/arel/version.rb
54
+ - lib/yiffspace/core_ext/active_record/all.rb
55
+ - lib/yiffspace/core_ext/active_record/cross_join_lateral.rb
56
+ - lib/yiffspace/core_ext/active_record/cross_unnest.rb
57
+ - lib/yiffspace/core_ext/active_record/left_join_lateral.rb
58
+ - lib/yiffspace/core_ext/active_record/left_unnest.rb
59
+ - lib/yiffspace/core_ext/active_record/unnest.rb
60
+ - lib/yiffspace/core_ext/arel/all.rb
61
+ - lib/yiffspace/core_ext/arel/cross_join_lateral.rb
62
+ - lib/yiffspace/core_ext/arel/left_join_lateral.rb
63
+ - lib/yiffspace/extensions/active_record/cross_join_lateral.rb
64
+ - lib/yiffspace/extensions/active_record/cross_unnest.rb
65
+ - lib/yiffspace/extensions/active_record/left_join_lateral.rb
66
+ - lib/yiffspace/extensions/active_record/left_unnest.rb
67
+ - lib/yiffspace/extensions/active_record/unnest.rb
68
+ - lib/yiffspace/extensions/arel/nodes/cross_join_lateral.rb
69
+ - lib/yiffspace/extensions/arel/nodes/left_join_lateral.rb
70
+ - lib/yiffspace/extensions/arel/table/cross_join_lateral.rb
71
+ - lib/yiffspace/extensions/arel/table/left_join_lateral.rb
72
+ - lib/yiffspace/extensions/arel/visitors/postgresql/cross_join_lateral.rb
73
+ - lib/yiffspace/extensions/arel/visitors/postgresql/left_join_lateral.rb
74
+ homepage: https://yiff.space
75
+ licenses:
76
+ - MIT
77
+ metadata:
78
+ allowed_push_host: https://rubygems.org
79
+ homepage_uri: https://yiff.space
80
+ source_code_uri: https://github.com/YiffSpace/Gem/tree/master/yiffspace-arel
81
+ changelog_uri: https://github.com/YiffSpace/Gem/blob/master/yiffspace-arel/CHANGELOG.md
82
+ rubygems_mfa_required: 'true'
83
+ rdoc_options: []
84
+ require_paths:
85
+ - lib
86
+ required_ruby_version: !ruby/object:Gem::Requirement
87
+ requirements:
88
+ - - ">="
89
+ - !ruby/object:Gem::Version
90
+ version: 3.4.1
91
+ required_rubygems_version: !ruby/object:Gem::Requirement
92
+ requirements:
93
+ - - ">="
94
+ - !ruby/object:Gem::Version
95
+ version: '0'
96
+ requirements: []
97
+ rubygems_version: 3.6.2
98
+ specification_version: 4
99
+ summary: Postgres lateral-join/unnest ActiveRecord & Arel extensions, for https://yiff.space
100
+ and related projects
101
+ test_files: []