exwiw 1.1.3 → 1.1.4
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 +4 -4
- data/CHANGELOG.md +6 -0
- data/README.md +1 -0
- data/lib/exwiw/query_ast_builder.rb +16 -10
- data/lib/exwiw/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: edfbfddf23cb6df92da93914c6ee111a1ca7fc0085f096e82b894c8a4573b398
|
|
4
|
+
data.tar.gz: 8a96062ee9e37c1a12daec122420c1e91a06194c5f1ba1aadc3a5a5bc303a534
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: f16c16b056138f857fcc54b1015eea30969989bb6604e5ea7fd99e2e0ab43d649a80dffc2e1887939f934ec951da28a53981a1debca854ad2bf006cf2f4cfaf3
|
|
7
|
+
data.tar.gz: e4e119962a0bc285f03e18e9540c5d7efd98b7d758240ab81f0274ee5cd44105dfeb0b15302734f5586f4e7ac4ad7933c331343090e0445aaee32c22c5e2459f
|
data/CHANGELOG.md
CHANGED
|
@@ -2,6 +2,12 @@
|
|
|
2
2
|
|
|
3
3
|
## [Unreleased]
|
|
4
4
|
|
|
5
|
+
## [1.1.4] - 2026-09-18
|
|
6
|
+
|
|
7
|
+
### Fixed
|
|
8
|
+
|
|
9
|
+
- **Polymorphic arms are grouped by the type column, so a config that gives each arm its own foreign key no longer loses rows.** The multi-arm walk keyed the group on `(foreign_key, foreign_type)`, which fits what the generators emit for Rails (`<name>_id` + `<name>_type`) but not a hand-written config where one type column selects between several foreign key columns — `merchant_application_type` choosing between `merchant_application_id` and `external_application_id`, say. Such arms were not recognised as siblings, so the table fell back to the single-path behavior: only the arm the BFS happened to settle on was extracted and every other arm's rows were dropped without a warning. Which arm survived depended on path length, so a table could even lose the arm it used to keep once a shorter one appeared. The group is now keyed on `foreign_type` alone and each arm joins on its own foreign key; two *independent* polymorphic associations have distinct type columns and stay in distinct groups, as before. Two consequences for such a table, both already true of the single-foreign-key case: its SQL becomes the `UNION` id-set form instead of a single JOIN, and `batch_scope` on it is now rejected in pre-flight (a batch of one terminus's ids does not constrain the other arms).
|
|
10
|
+
|
|
5
11
|
## [1.1.3] - 2026-09-08
|
|
6
12
|
|
|
7
13
|
### Fixed
|
data/README.md
CHANGED
|
@@ -811,6 +811,7 @@ Notes:
|
|
|
811
811
|
- **Only arms that reach the scope are included.** An arm whose target has no scope of its own is dropped, never widened — an unscoped arm would pull in every tenant's rows. An arm marked `"ignore": true` is dropped as usual, before any of this.
|
|
812
812
|
- An arm's target does not need a `belongs_to` path to a scoped table: if it is scoped by other means (referenced-by, [`reverse_scope`](#reverse-scope-for-multi-referencer-tables-reverse_scope), or the parent cascade) the arm probes that query's ids instead, still pinned by the type column.
|
|
813
813
|
- An arm whose target is scoped **through this same table** (e.g. `active_storage_blobs`, narrowed by referenced-by from `active_storage_attachments`, appearing as an `ActiveStorage::Blob` arm of those same attachments) is dropped: adopting it would make the two tables scope each other and leave the referenced table short of rows the join table kept — a dangling foreign key on import.
|
|
814
|
+
- **Arms are grouped by the type column (`foreign_type`), not by the foreign key.** Rails keeps every arm's id in one `<name>_id` column, which is what the generators emit, but a hand-written config may give each arm its own foreign key while one type column still selects between them — e.g. `merchant_application_type` choosing between `merchant_application_id` and `external_application_id`. Those are arms of the same discriminator, so each is resolved and joined on its own key. Two *independent* polymorphic associations on one table have distinct type columns and therefore stay in distinct groups.
|
|
814
815
|
- Nothing changes when there is a single arm, or when the walk leaves through a non-polymorphic `belongs_to`: the plain single-JOIN SQL is emitted, byte for byte as before.
|
|
815
816
|
- This applies to the scope-column mode walk. The single `--target-table` mode still follows one path per table.
|
|
816
817
|
|
|
@@ -880,7 +880,7 @@ module Exwiw
|
|
|
880
880
|
# single shortest path `find_path_to_scoped` returns is the whole story and
|
|
881
881
|
# this returns one arm — the historical behavior, byte-for-byte.
|
|
882
882
|
#
|
|
883
|
-
# A *polymorphic* hop is different: one (
|
|
883
|
+
# A *polymorphic* hop is different: one type column (`foreign_type`)
|
|
884
884
|
# addresses several parent tables — one per `type_value` — and each row
|
|
885
885
|
# belongs to whichever arm its type column names. Following a single path
|
|
886
886
|
# therefore extracts only the rows of that one arm and silently drops every
|
|
@@ -888,7 +888,7 @@ module Exwiw
|
|
|
888
888
|
# settles on one owner table and the query filters `record_type = '<that
|
|
889
889
|
# one>'`, so attachments of the other 20-odd owner types never make it into
|
|
890
890
|
# the dump.) So when the shortest path leaves through a polymorphic relation,
|
|
891
|
-
# resolve every sibling arm
|
|
891
|
+
# resolve every sibling arm sharing its type column.
|
|
892
892
|
#
|
|
893
893
|
# Note the entry condition: this only ever widens a table that *already*
|
|
894
894
|
# reaches the scope through a polymorphic join path. A table with no path at
|
|
@@ -967,11 +967,19 @@ module Exwiw
|
|
|
967
967
|
ScopedArm.new(relation: relation, target_query: target_query)
|
|
968
968
|
end
|
|
969
969
|
|
|
970
|
-
# The polymorphic belongs_to arms sharing the
|
|
971
|
-
#
|
|
972
|
-
#
|
|
973
|
-
#
|
|
974
|
-
#
|
|
970
|
+
# The polymorphic belongs_to arms sharing the `foreign_type` of the relation
|
|
971
|
+
# this table uses to reach `first_hop_table_name`, or nil when the caller
|
|
972
|
+
# should stay on the single-path behavior: the hop is not polymorphic, or its
|
|
973
|
+
# group has only one arm, or this table has no usable primary key to union
|
|
974
|
+
# the arms on.
|
|
975
|
+
#
|
|
976
|
+
# The group is keyed on the type column alone. A Rails association stores
|
|
977
|
+
# every arm's id in one column, but a hand-written config may give each arm
|
|
978
|
+
# its own foreign key while one type column still selects between them; both
|
|
979
|
+
# are arms of the same discriminator, and everything downstream reads
|
|
980
|
+
# `foreign_key` off the arm's own relation. Two *independent* polymorphic
|
|
981
|
+
# associations on one table have distinct type columns, so they stay in
|
|
982
|
+
# distinct groups.
|
|
975
983
|
#
|
|
976
984
|
# The relation is looked up with `belongs_to(table_name)` — the same lookup
|
|
977
985
|
# #build_scoped_join_clause performs — so the decision is made about exactly
|
|
@@ -983,9 +991,7 @@ module Exwiw
|
|
|
983
991
|
return nil if relation.nil? || !relation.polymorphic?
|
|
984
992
|
|
|
985
993
|
arms = table.belongs_tos.select do |other|
|
|
986
|
-
other.polymorphic? &&
|
|
987
|
-
other.foreign_key == relation.foreign_key &&
|
|
988
|
-
other.foreign_type == relation.foreign_type
|
|
994
|
+
other.polymorphic? && other.foreign_type == relation.foreign_type
|
|
989
995
|
end
|
|
990
996
|
arms.size > 1 ? arms : nil
|
|
991
997
|
end
|
data/lib/exwiw/version.rb
CHANGED