mirror of
https://github.com/ModernRelay/omnigraph.git
synced 2026-06-09 01:35:18 +02:00
Exercise actual type rename in schema-apply rename test
The previous version of `apply_schema_renames_node_type_via_rename_from_and_preserves_rows`
kept the node name as `Person` (`@rename_from("Person")`) and only renamed
a property. The planner only emits a `RenameType` step when the new name
differs from the accepted one, so the test name overstated what it
covered: a regression in `RenameType` step emission or in the
coordinator's table-key remap during type rename could pass while the
test still went green.
Rename the desired node from `Person` to `Human` (with
`@rename_from("Person")`), update the dependent edge endpoints to point
at `Human`, and assert both the `RenameType` step and that the manifest
table key has moved from `node:Person` to `node:Human`.
This commit is contained in:
parent
e22d468e27
commit
57a62756c5
1 changed files with 47 additions and 16 deletions
|
|
@ -262,8 +262,9 @@ async fn plan_schema_for_property_type_narrowing_is_not_supported() {
|
|||
async fn apply_schema_renames_node_type_via_rename_from_and_preserves_rows() {
|
||||
// Covers the stable-type-id contract: renaming a type preserves the
|
||||
// underlying Lance dataset (by stable id), so existing rows survive the
|
||||
// rename. This is the "supported" half of the destructive-vs-supported
|
||||
// boundary that the rejections above cover.
|
||||
// rename and become queryable under the new table key. This is the
|
||||
// "supported" half of the destructive-vs-supported boundary that the
|
||||
// rejections above cover.
|
||||
let dir = tempfile::tempdir().unwrap();
|
||||
let mut db = init_and_load(&dir).await;
|
||||
let people_before = count_rows(&db, "node:Person").await;
|
||||
|
|
@ -272,8 +273,10 @@ async fn apply_schema_renames_node_type_via_rename_from_and_preserves_rows() {
|
|||
"fixture should seed Person rows for this test to be meaningful"
|
||||
);
|
||||
|
||||
// Rename Person -> Human (and the keying property name -> full_name).
|
||||
// Edges that referenced Person must update to Human in the same migration.
|
||||
let desired = r#"
|
||||
node Person @rename_from("Person") {
|
||||
node Human @rename_from("Person") {
|
||||
full_name: String @key @rename_from("name")
|
||||
age: I32?
|
||||
}
|
||||
|
|
@ -282,25 +285,53 @@ node Company {
|
|||
name: String @key
|
||||
}
|
||||
|
||||
edge Knows: Person -> Person {
|
||||
edge Knows: Human -> Human {
|
||||
since: Date?
|
||||
}
|
||||
|
||||
edge WorksAt: Person -> Company
|
||||
edge WorksAt: Human -> Company
|
||||
"#;
|
||||
|
||||
let result = db.apply_schema(desired).await.unwrap();
|
||||
assert!(result.supported && result.applied);
|
||||
assert!(result.steps.iter().any(|step| matches!(
|
||||
step,
|
||||
SchemaMigrationStep::RenameProperty {
|
||||
type_kind: SchemaTypeKind::Node,
|
||||
type_name,
|
||||
from,
|
||||
to,
|
||||
} if type_name == "Person" && from == "name" && to == "full_name"
|
||||
)));
|
||||
|
||||
// Rows survive the property rename.
|
||||
assert_eq!(count_rows(&db, "node:Person").await, people_before);
|
||||
// Type rename is emitted as a RenameType step.
|
||||
assert!(
|
||||
result.steps.iter().any(|step| matches!(
|
||||
step,
|
||||
SchemaMigrationStep::RenameType {
|
||||
type_kind: SchemaTypeKind::Node,
|
||||
from,
|
||||
to,
|
||||
} if from == "Person" && to == "Human"
|
||||
)),
|
||||
"expected RenameType Person -> Human in {:?}",
|
||||
result.steps
|
||||
);
|
||||
// Property rename rides along under the new type name.
|
||||
assert!(
|
||||
result.steps.iter().any(|step| matches!(
|
||||
step,
|
||||
SchemaMigrationStep::RenameProperty {
|
||||
type_kind: SchemaTypeKind::Node,
|
||||
type_name,
|
||||
from,
|
||||
to,
|
||||
} if type_name == "Human" && from == "name" && to == "full_name"
|
||||
)),
|
||||
"expected RenameProperty name -> full_name on Human in {:?}",
|
||||
result.steps
|
||||
);
|
||||
|
||||
// Rows survive: table key now resolves under the new type name and the
|
||||
// old key is gone.
|
||||
assert_eq!(count_rows(&db, "node:Human").await, people_before);
|
||||
assert!(
|
||||
db.snapshot_of(ReadTarget::branch("main"))
|
||||
.await
|
||||
.unwrap()
|
||||
.entry("node:Person")
|
||||
.is_none(),
|
||||
"old node:Person table key should be unmapped after rename"
|
||||
);
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue