Skip to content

Commit

Permalink
Fix schema ordering bugs with rewrites (#6154)
Browse files Browse the repository at this point in the history
Rewrites were grabbing the wrong object as the source
  • Loading branch information
msullivan committed Sep 23, 2023
1 parent a2e264f commit 7e5ad53
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 2 deletions.
4 changes: 2 additions & 2 deletions edb/edgeql/declarative.py
Original file line number Diff line number Diff line change
Expand Up @@ -879,14 +879,14 @@ def trace_Rewrite(
) -> None:
exprs = [ExprDependency(expr=node.expr)]

obj = ctx.depstack[-1][1]
obj = ctx.depstack[-2][1]
_register_item(
node,
deps=set(),
hard_dep_exprs=exprs,
source=obj,
subject=obj,
anchors={'__specified__': obj},
anchors={'__old__': obj},
ctx=ctx,
)

Expand Down
22 changes: 22 additions & 0 deletions tests/test_schema.py
Original file line number Diff line number Diff line change
Expand Up @@ -1459,6 +1459,28 @@ def test_schema_rewrite_missing_required_01(self):
}
"""

def test_schema_rewrite_order_01(self):
"""
type EventSession extending Timed {
lastSeen: datetime {
rewrite update using (
__old__.foo
)
}
lastSeen2: datetime {
rewrite insert using (
__subject__.foo
)
}
}
abstract type Timed {
required foo: datetime {
default := datetime_current();
}
}
"""

def test_schema_property_cardinality_alter_01(self):
schema = self.load_schema('''
type Foo {
Expand Down

0 comments on commit 7e5ad53

Please sign in to comment.