exwiw 1.1.5 → 1.1.7

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.
data/lib/exwiw.rb CHANGED
@@ -64,7 +64,46 @@ module Exwiw
64
64
  # (`scope_column IN ids`) and tables lacking it are reached by walking
65
65
  # belongs_to up to the nearest table that has it. When set, `table_name` is
66
66
  # nil. SQL adapters only.
67
- DumpTarget = Struct.new(:table_name, :ids, :ids_field, :scope_column, keyword_init: true)
67
+ #
68
+ # `ids` maps an ID space name to its values. A table's `scope_column` values
69
+ # belong to the ID space it declares (`id_space`, `default` when omitted), so
70
+ # groups of tables keyed by unrelated kinds of id can be scoped in one run. An
71
+ # Array is taken as the values of the `default` space. Single-target mode and
72
+ # the mongodb adapter use the `default` space only.
73
+ DEFAULT_ID_SPACE = "default"
74
+ ID_SPACE_NAME_PATTERN = /\A[a-z][a-z0-9_]*\z/
75
+
76
+ DumpTarget = Struct.new(:table_name, :ids, :ids_field, :scope_column, keyword_init: true) do
77
+ def self.normalize_ids(ids)
78
+ case ids
79
+ when nil then {}
80
+ when Hash then ids.to_h { |space, values| [space.to_s, Array(values)] }
81
+ else { DEFAULT_ID_SPACE => Array(ids) }
82
+ end
83
+ end
84
+
85
+ def initialize(**kwargs)
86
+ super
87
+ self.ids = ids
88
+ end
89
+
90
+ def ids=(value)
91
+ self[:ids] = self.class.normalize_ids(value)
92
+ end
93
+
94
+ def ids_for(id_space)
95
+ ids.fetch(id_space, [])
96
+ end
97
+
98
+ def default_ids
99
+ ids_for(DEFAULT_ID_SPACE)
100
+ end
101
+
102
+ # ID spaces other than `default` that were given, with or without values.
103
+ def named_id_spaces
104
+ ids.keys - [DEFAULT_ID_SPACE]
105
+ end
106
+ end
68
107
  # `uri` is an optional full connection string (currently only honored by the
69
108
  # mongodb adapter, e.g. `mongodb+srv://...`). When present it is the source of
70
109
  # truth for the connection — host/port/user/password are ignored — so TLS,
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: exwiw
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.1.5
4
+ version: 1.1.7
5
5
  platform: ruby
6
6
  authors:
7
7
  - Shia
@@ -65,6 +65,7 @@ files:
65
65
  - docs/plans/2026-06-19-mongodb-export-remove-parallelism-native-ext.md
66
66
  - docs/row-transform-masking-notes.md
67
67
  - docs/scope-column-redesign.md
68
+ - docs/scope-id-set-join-notes.md
68
69
  - docs/sql-dump-optimization-notes.md
69
70
  - exe/exwiw
70
71
  - ext/exwiw/ext_json/ext_json.c