busload 0.1.0 → 0.1.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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: b5ce9146375a0bccfc5c4dd30fff9ebcff803353ae9b2cd7bfb65cb8cf02c08d
4
- data.tar.gz: 2461e6d139e75fbc8d9c436321d50596f082e5c9de6367d8314ae9f7b12f6bf3
3
+ metadata.gz: '09d9798877116d2186960b5c766122a951901fd3227aeb313b75c65a1d0d5a53'
4
+ data.tar.gz: 7263aa5982b548da1edbb75e614e21b0004af69a945a0c02a10f719b1a525ef1
5
5
  SHA512:
6
- metadata.gz: b43fcfc80582658d1d80272ca0f948548b1526522bcd0e3098c4ce63bfb49f03bff0726eb085f374c4a5c069dde9f9d0f7da0ca63c8791a302def651fc8e346f
7
- data.tar.gz: 95e7a1f34d090c05ae61472b4ca7f981b451758caf8ed00e58b1348fad1015c4a786085c6e9afae267cc17ccf2e64deecf4ae8969cab4fefe412f6a569a524a9
6
+ metadata.gz: 6b07591f0b447d971a07ed5fbc3e9acf68ac98c82f1b51063f343de42aafd1a1ee0defdd624b8ad6a38dc4c30cffc1105190d2bf615dcec0673f576d6a13c299
7
+ data.tar.gz: 90f1bdd069f47353df473590ab044c98526bed448d4924bf7982eb774d21106c10e6d8f9e64b021c365db95cc1e86517822b8eb39d09fa35f2a99b297a5b5dd4
data/CHANGELOG.md CHANGED
@@ -1,5 +1,9 @@
1
1
  ## [Unreleased]
2
2
 
3
+ ## [0.1.1] - 2026-11-30
4
+
5
+ - Fixed error for deeply nested or long-named preloads
6
+
3
7
  ## [0.1.0] - 2026-11-30
4
8
 
5
9
  - Initial release
data/README.md CHANGED
@@ -37,19 +37,19 @@ WITH
37
37
  WHERE active
38
38
  ORDER BY name
39
39
  ),
40
- "busload_0/posts" AS (
40
+ "busload_0_1" AS (
41
41
  SELECT posts.*
42
42
  FROM posts
43
43
  WHERE user_id IN (SELECT id FROM "busload_0")
44
44
  ),
45
- "busload_0/posts/comments" AS (
45
+ "busload_0_1_1" AS (
46
46
  SELECT comments.*
47
47
  FROM comments
48
- WHERE post_id IN (SELECT id FROM "busload_0/posts")
48
+ WHERE post_id IN (SELECT id FROM "busload_0_1")
49
49
  )
50
50
  SELECT 0, t::text FROM "busload_0" t
51
- UNION ALL SELECT 1, t::text FROM "busload_0/posts" t
52
- UNION ALL SELECT 2, t::text FROM "busload_0/posts/comments" t
51
+ UNION ALL SELECT 1, t::text FROM "busload_0_1" t
52
+ UNION ALL SELECT 2, t::text FROM "busload_0_1_1" t
53
53
  ```
54
54
 
55
55
  Works on associations too:
@@ -18,6 +18,7 @@ module Busload
18
18
  @owner = owner
19
19
  @association = association
20
20
  @preloader = preloader
21
+ @children = 0
21
22
  @sql = @relation.to_sql
22
23
  @join_dependency = join_dependency if @relation.eager_loading?
23
24
  end
@@ -37,7 +38,7 @@ module Busload
37
38
  def cte_for(association)
38
39
  table = Arel::Table.new(name)
39
40
  relation = association.relation_for(table.project(table[association.reflection.join_foreign_key]))
40
- CTE.new(relation, "#{name}/#{association.reflection.name}", owner: self, association:)
41
+ CTE.new(relation, "#{name}_#{@children += 1}", owner: self, association:)
41
42
  end
42
43
 
43
44
  def load(result)
data/lib/busload/load.rb CHANGED
@@ -33,7 +33,6 @@ module Busload
33
33
 
34
34
  def run
35
35
  @ctes.first.model.with_connection do |connection|
36
- ensure_names_fit(connection)
37
36
  results = Adapters.for(connection).select_all(@ctes.to_h { |cte| [cte.name, cte.sql] })
38
37
  @ctes.zip(results) { |cte, result| cte.load(result) }
39
38
  end
@@ -74,12 +73,6 @@ module Busload
74
73
  end
75
74
  end
76
75
 
77
- # Databases cut off long names, which could make two CTEs share one.
78
- def ensure_names_fit(connection)
79
- too_long = @ctes.find { |cte| cte.name.bytesize > connection.max_identifier_length }
80
- raise Error, "Busload's CTE name #{too_long.name} is too long; preload fewer levels deep" if too_long
81
- end
82
-
83
76
  # Includes that become a JOIN load with the relation, not as preloads.
84
77
  def preloads_for(relation)
85
78
  return [] if relation.skip_preloading_value
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Busload
4
- VERSION = "0.1.0"
4
+ VERSION = "0.1.1"
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: busload
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.1.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jason Dougherty