Swift: Fix key path numbering in upgrade and downgrade scripts

This commit is contained in:
Jeroen Ketema
2025-10-31 11:01:04 +01:00
parent 92ca0c2b62
commit 7301bc74cf
2 changed files with 13 additions and 3 deletions

View File

@@ -19,14 +19,19 @@ class ValueDeclOrNone extends @value_decl_or_none {
}
predicate isKeyPathComponentWithNewKind(KeyPathComponent id) {
key_path_components(id, 3, _) or key_path_components(id, 4, _)
key_path_components(id, 1, _) or key_path_components(id, 4, _)
}
query predicate new_key_path_components(KeyPathComponent id, int kind, TypeOrNone component_type) {
exists(int old_kind |
key_path_components(id, old_kind, component_type) and
not isKeyPathComponentWithNewKind(id) and
if old_kind < 5 then kind = old_kind else kind = old_kind - 2
if old_kind = 0
then kind = old_kind
else
if old_kind = 2 or old_kind = 3
then kind = old_kind - 1
else kind = old_kind - 2
)
}

View File

@@ -9,5 +9,10 @@ class TypeOrNone extends @type_or_none {
from KeyPathComponent id, int kind, int new_kind, TypeOrNone component_type
where
key_path_components(id, kind, component_type) and
if kind < 3 then new_kind = kind else new_kind = kind + 2
if kind = 0
then new_kind = kind
else
if kind = 1 or kind = 2
then new_kind = kind + 1
else new_kind = kind + 2
select id, new_kind, component_type