style: format the whole tree with cargo fmt (stock defaults, #35)
One-time, mechanical reformat — no functional changes. The tree was not rustfmt-clean (~1800 hunks across ~100 files); this brings it to stock `cargo fmt` defaults so a `cargo fmt --check` CI gate can follow. Behaviour-preserving: 2509 pass / 0 fail / 1 ignored (unchanged baseline), clippy clean. A .git-blame-ignore-revs entry follows so `git blame` skips this commit.
This commit is contained in:
+200
-56
@@ -30,8 +30,7 @@ fn rt() -> tokio::runtime::Runtime {
|
||||
|
||||
fn open() -> (project::Project, Database, tempfile::TempDir) {
|
||||
let dir = tempfile::tempdir().expect("create tempdir");
|
||||
let project =
|
||||
project::open_or_create(None, Some(dir.path())).expect("open or create project");
|
||||
let project = project::open_or_create(None, Some(dir.path())).expect("open or create project");
|
||||
let db = Database::open_with_persistence(
|
||||
project.db_path(),
|
||||
Persistence::new(project.path().to_path_buf()),
|
||||
@@ -42,8 +41,7 @@ fn open() -> (project::Project, Database, tempfile::TempDir) {
|
||||
|
||||
fn open_with_undo() -> (project::Project, Database, tempfile::TempDir) {
|
||||
let dir = tempfile::tempdir().expect("create tempdir");
|
||||
let project =
|
||||
project::open_or_create(None, Some(dir.path())).expect("open or create project");
|
||||
let project = project::open_or_create(None, Some(dir.path())).expect("open or create project");
|
||||
let db = Database::open_with_persistence_and_undo(
|
||||
project.db_path(),
|
||||
Persistence::new(project.path().to_path_buf()),
|
||||
@@ -159,7 +157,10 @@ fn e2e_alter_table_add_rename_drop_and_raw_default_check() {
|
||||
// Final schema: id, label (renamed from v), qty; `note` added then
|
||||
// dropped.
|
||||
let cols = column_names(&db, &r);
|
||||
assert_eq!(cols, vec!["id".to_string(), "label".to_string(), "qty".to_string()]);
|
||||
assert_eq!(
|
||||
cols,
|
||||
vec!["id".to_string(), "label".to_string(), "qty".to_string()]
|
||||
);
|
||||
|
||||
// The DEFAULT backfilled the pre-existing row to qty = 0.
|
||||
let rows = r
|
||||
@@ -168,14 +169,21 @@ fn e2e_alter_table_add_rename_drop_and_raw_default_check() {
|
||||
.rows;
|
||||
assert_eq!(rows.len(), 1);
|
||||
// qty is the third column; the rebuild backfilled the default.
|
||||
assert_eq!(rows[0][2].as_deref(), Some("0"), "DEFAULT 0 backfilled the existing row");
|
||||
assert_eq!(
|
||||
rows[0][2].as_deref(),
|
||||
Some("0"),
|
||||
"DEFAULT 0 backfilled the existing row"
|
||||
);
|
||||
|
||||
// The CHECK (qty >= 0) is enforced: a negative qty is refused.
|
||||
assert!(
|
||||
r.block_on(db.insert(
|
||||
"T".to_string(),
|
||||
Some(vec!["id".to_string(), "qty".to_string()]),
|
||||
vec![Value::Number("2".to_string()), Value::Number("-1".to_string())],
|
||||
vec![
|
||||
Value::Number("2".to_string()),
|
||||
Value::Number("-1".to_string())
|
||||
],
|
||||
Some("insert".to_string()),
|
||||
))
|
||||
.is_err(),
|
||||
@@ -185,7 +193,10 @@ fn e2e_alter_table_add_rename_drop_and_raw_default_check() {
|
||||
r.block_on(db.insert(
|
||||
"T".to_string(),
|
||||
Some(vec!["id".to_string(), "qty".to_string()]),
|
||||
vec![Value::Number("3".to_string()), Value::Number("7".to_string())],
|
||||
vec![
|
||||
Value::Number("3".to_string()),
|
||||
Value::Number("7".to_string()),
|
||||
],
|
||||
Some("insert".to_string()),
|
||||
))
|
||||
.expect("qty = 7 satisfies the CHECK");
|
||||
@@ -214,7 +225,10 @@ fn e2e_alter_add_column_survives_rebuild() {
|
||||
r.block_on(db.insert(
|
||||
"T".to_string(),
|
||||
Some(vec!["id".to_string(), "qty".to_string()]),
|
||||
vec![Value::Number("1".to_string()), Value::Number("-5".to_string())],
|
||||
vec![
|
||||
Value::Number("1".to_string()),
|
||||
Value::Number("-5".to_string())
|
||||
],
|
||||
Some("insert".to_string()),
|
||||
))
|
||||
.is_err(),
|
||||
@@ -257,9 +271,17 @@ fn e2e_alter_column_type_clean_and_lossy_convert() {
|
||||
.rows;
|
||||
assert_eq!(rows.len(), 1);
|
||||
// v (col 1): lossy real→int performed → 3.7 stored as 3.
|
||||
assert_eq!(rows[0][1].as_deref(), Some("3"), "lossy real→int performed (3.7→3)");
|
||||
assert_eq!(
|
||||
rows[0][1].as_deref(),
|
||||
Some("3"),
|
||||
"lossy real→int performed (3.7→3)"
|
||||
);
|
||||
// w (col 2): clean int→text stringified → "42".
|
||||
assert_eq!(rows[0][2].as_deref(), Some("42"), "clean int→text stringified");
|
||||
assert_eq!(
|
||||
rows[0][2].as_deref(),
|
||||
Some("42"),
|
||||
"clean int→text stringified"
|
||||
);
|
||||
|
||||
// The columns now carry the new user-facing types (round-tripped
|
||||
// through the metadata).
|
||||
@@ -290,12 +312,20 @@ fn e2e_alter_column_type_int_to_serial_is_allowed() {
|
||||
}
|
||||
other => panic!("expected ReplayCompleted, got {other:?} (events: {events:?})"),
|
||||
}
|
||||
assert_eq!(col_type(&db, &r, "n"), Some(Type::Serial), "int→serial converted the column");
|
||||
assert_eq!(
|
||||
col_type(&db, &r, "n"),
|
||||
Some(Type::Serial),
|
||||
"int→serial converted the column"
|
||||
);
|
||||
let rows = r
|
||||
.block_on(db.query_data("T".to_string(), None, None))
|
||||
.expect("query")
|
||||
.rows;
|
||||
assert_eq!(rows[0][1].as_deref(), Some("100"), "the existing value is preserved");
|
||||
assert_eq!(
|
||||
rows[0][1].as_deref(),
|
||||
Some("100"),
|
||||
"the existing value is preserved"
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
@@ -368,11 +398,19 @@ fn e2e_alter_column_type_survives_rebuild() {
|
||||
)
|
||||
.expect("write script");
|
||||
r.block_on(run_replay(&db, project.path(), "conv.commands"));
|
||||
assert_eq!(col_type(&db, &r, "v"), Some(Type::Int), "converted before rebuild");
|
||||
assert_eq!(
|
||||
col_type(&db, &r, "v"),
|
||||
Some(Type::Int),
|
||||
"converted before rebuild"
|
||||
);
|
||||
|
||||
r.block_on(db.rebuild_from_text(project.path().to_path_buf(), Some("rebuild".to_string())))
|
||||
.expect("rebuild");
|
||||
assert_eq!(col_type(&db, &r, "v"), Some(Type::Int), "the converted type survives rebuild");
|
||||
assert_eq!(
|
||||
col_type(&db, &r, "v"),
|
||||
Some(Type::Int),
|
||||
"the converted type survives rebuild"
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
@@ -393,14 +431,22 @@ fn e2e_alter_column_type_is_one_undo_step() {
|
||||
)
|
||||
.expect("write script");
|
||||
r.block_on(run_replay(&db, project.path(), "conv.commands"));
|
||||
assert_eq!(col_type(&db, &r, "v"), Some(Type::Int), "the SQL ALTER COLUMN TYPE converted v");
|
||||
assert_eq!(
|
||||
col_type(&db, &r, "v"),
|
||||
Some(Type::Int),
|
||||
"the SQL ALTER COLUMN TYPE converted v"
|
||||
);
|
||||
|
||||
// A single undo reverts the whole conversion.
|
||||
assert!(
|
||||
r.block_on(db.undo()).expect("undo").is_some(),
|
||||
"the conversion was one undo step"
|
||||
);
|
||||
assert_eq!(col_type(&db, &r, "v"), Some(Type::Real), "one undo restored the pre-conversion type");
|
||||
assert_eq!(
|
||||
col_type(&db, &r, "v"),
|
||||
Some(Type::Real),
|
||||
"one undo restored the pre-conversion type"
|
||||
);
|
||||
}
|
||||
|
||||
// --- 4g: ADD/DROP constraint + ADD foreign key (ADR-0035 §4g) -----------
|
||||
@@ -410,7 +456,10 @@ fn insert_t_qty_ok(db: &Database, r: &tokio::runtime::Runtime, id: i64, qty: i64
|
||||
r.block_on(db.insert(
|
||||
"T".to_string(),
|
||||
Some(vec!["id".to_string(), "qty".to_string()]),
|
||||
vec![Value::Number(id.to_string()), Value::Number(qty.to_string())],
|
||||
vec![
|
||||
Value::Number(id.to_string()),
|
||||
Value::Number(qty.to_string()),
|
||||
],
|
||||
Some("insert".to_string()),
|
||||
))
|
||||
.is_ok()
|
||||
@@ -436,14 +485,23 @@ fn e2e_add_named_check_enforced_and_survives_rebuild_with_its_name() {
|
||||
"events: {events:?}"
|
||||
);
|
||||
// Enforced: qty = -1 refused, qty = 5 accepted.
|
||||
assert!(!insert_t_qty_ok(&db, &r, 1, -1), "the CHECK rejects qty = -1");
|
||||
assert!(insert_t_qty_ok(&db, &r, 2, 5), "qty = 5 satisfies the CHECK");
|
||||
assert!(
|
||||
!insert_t_qty_ok(&db, &r, 1, -1),
|
||||
"the CHECK rejects qty = -1"
|
||||
);
|
||||
assert!(
|
||||
insert_t_qty_ok(&db, &r, 2, 5),
|
||||
"qty = 5 satisfies the CHECK"
|
||||
);
|
||||
|
||||
// Rebuild from text, then DROP CONSTRAINT by name must still work →
|
||||
// the name survived the round-trip.
|
||||
r.block_on(db.rebuild_from_text(project.path().to_path_buf(), Some("rebuild".to_string())))
|
||||
.expect("rebuild");
|
||||
assert!(!insert_t_qty_ok(&db, &r, 3, -2), "the CHECK is intact after rebuild");
|
||||
assert!(
|
||||
!insert_t_qty_ok(&db, &r, 3, -2),
|
||||
"the CHECK is intact after rebuild"
|
||||
);
|
||||
std::fs::write(
|
||||
project.path().join("drop.commands"),
|
||||
"alter table T drop constraint qty_positive\n",
|
||||
@@ -502,13 +560,19 @@ fn e2e_add_composite_unique_enforced_and_survives_rebuild() {
|
||||
))
|
||||
.is_ok()
|
||||
};
|
||||
assert!(!dup_ok(2, 1, 2), "the composite UNIQUE rejects the duplicate (1, 2)");
|
||||
assert!(
|
||||
!dup_ok(2, 1, 2),
|
||||
"the composite UNIQUE rejects the duplicate (1, 2)"
|
||||
);
|
||||
assert!(dup_ok(3, 1, 3), "(1, 3) is distinct and accepted");
|
||||
|
||||
// Survives rebuild (the unique_constraints yaml path).
|
||||
r.block_on(db.rebuild_from_text(project.path().to_path_buf(), Some("rebuild".to_string())))
|
||||
.expect("rebuild");
|
||||
assert!(!dup_ok(4, 1, 2), "the composite UNIQUE is intact after rebuild");
|
||||
assert!(
|
||||
!dup_ok(4, 1, 2),
|
||||
"the composite UNIQUE is intact after rebuild"
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
@@ -559,7 +623,10 @@ fn e2e_drop_composite_unique_by_derived_name() {
|
||||
.is_ok()
|
||||
};
|
||||
assert!(dup_ok(1, 1, 2), "first (1, 2) accepted");
|
||||
assert!(!dup_ok(2, 1, 2), "duplicate (1, 2) rejected while the UNIQUE stands");
|
||||
assert!(
|
||||
!dup_ok(2, 1, 2),
|
||||
"duplicate (1, 2) rejected while the UNIQUE stands"
|
||||
);
|
||||
|
||||
// Drop the UNIQUE by its derived name through the existing DROP
|
||||
// CONSTRAINT grammar.
|
||||
@@ -572,7 +639,10 @@ fn e2e_drop_composite_unique_by_derived_name() {
|
||||
|
||||
// The UNIQUE no longer enforces: the previously-rejected duplicate is
|
||||
// now accepted.
|
||||
assert!(dup_ok(3, 1, 2), "duplicate (1, 2) accepted after the UNIQUE was dropped");
|
||||
assert!(
|
||||
dup_ok(3, 1, 2),
|
||||
"duplicate (1, 2) accepted after the UNIQUE was dropped"
|
||||
);
|
||||
|
||||
// And it stays gone across a rebuild from text.
|
||||
r.block_on(db.rebuild_from_text(project.path().to_path_buf(), Some("rebuild".to_string())))
|
||||
@@ -676,8 +746,14 @@ fn e2e_add_foreign_key_missing_child_column_refuses_without_dsl_flag() {
|
||||
let AppEvent::ReplayFailed { error, .. } = events.last().expect("an event") else {
|
||||
panic!("expected ReplayFailed; events: {events:?}");
|
||||
};
|
||||
assert!(!error.contains("--create-fk"), "no DSL flag in the SQL refusal; got: {error}");
|
||||
assert!(error.contains("pid"), "names the missing column; got: {error}");
|
||||
assert!(
|
||||
!error.contains("--create-fk"),
|
||||
"no DSL flag in the SQL refusal; got: {error}"
|
||||
);
|
||||
assert!(
|
||||
error.contains("pid"),
|
||||
"names the missing column; got: {error}"
|
||||
);
|
||||
assert!(
|
||||
error.to_lowercase().contains("add it first")
|
||||
|| error.to_lowercase().contains("does not exist"),
|
||||
@@ -709,12 +785,21 @@ fn e2e_add_foreign_key_creates_an_enforced_relationship() {
|
||||
r.block_on(db.insert(
|
||||
"C".to_string(),
|
||||
Some(vec!["cid".to_string(), "pid".to_string()]),
|
||||
vec![Value::Number(cid.to_string()), Value::Number(pid.to_string())],
|
||||
vec![
|
||||
Value::Number(cid.to_string()),
|
||||
Value::Number(pid.to_string()),
|
||||
],
|
||||
Some("insert".to_string()),
|
||||
))
|
||||
};
|
||||
assert!(insert_c(10, 1).is_ok(), "a child referencing parent id=1 is accepted");
|
||||
assert!(insert_c(11, 999).is_err(), "a child referencing a missing parent is rejected");
|
||||
assert!(
|
||||
insert_c(10, 1).is_ok(),
|
||||
"a child referencing parent id=1 is accepted"
|
||||
);
|
||||
assert!(
|
||||
insert_c(11, 999).is_err(),
|
||||
"a child referencing a missing parent is rejected"
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
@@ -740,7 +825,10 @@ fn e2e_drop_constraint_removes_a_named_foreign_key() {
|
||||
r.block_on(db.insert(
|
||||
"C".to_string(),
|
||||
Some(vec!["cid".to_string(), "pid".to_string()]),
|
||||
vec![Value::Number("1".to_string()), Value::Number("999".to_string())],
|
||||
vec![
|
||||
Value::Number("1".to_string()),
|
||||
Value::Number("999".to_string())
|
||||
],
|
||||
Some("insert".to_string()),
|
||||
))
|
||||
.is_ok(),
|
||||
@@ -798,7 +886,10 @@ fn e2e_add_constraint_is_one_undo_step() {
|
||||
"the ADD CONSTRAINT was one undo step"
|
||||
);
|
||||
// After undo the CHECK is gone: qty = -1 is accepted.
|
||||
assert!(insert_t_qty_ok(&db, &r, 3, -1), "one undo removed the CHECK");
|
||||
assert!(
|
||||
insert_t_qty_ok(&db, &r, 3, -1),
|
||||
"one undo removed the CHECK"
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
@@ -819,7 +910,10 @@ fn e2e_named_check_metadata_survives_a_fresh_rebuild() {
|
||||
.expect("db");
|
||||
r.block_on(db.sql_create_table(
|
||||
"T".to_string(),
|
||||
vec![ColumnSpec::new("id", Type::Int), ColumnSpec::new("qty", Type::Int)],
|
||||
vec![
|
||||
ColumnSpec::new("id", Type::Int),
|
||||
ColumnSpec::new("qty", Type::Int),
|
||||
],
|
||||
vec!["id".to_string()],
|
||||
vec![],
|
||||
vec![],
|
||||
@@ -846,7 +940,8 @@ fn e2e_named_check_metadata_survives_a_fresh_rebuild() {
|
||||
Persistence::new(project.path().to_path_buf()),
|
||||
)
|
||||
.unwrap();
|
||||
r.block_on(db.rebuild_from_text(project.path().to_path_buf(), None)).expect("rebuild");
|
||||
r.block_on(db.rebuild_from_text(project.path().to_path_buf(), None))
|
||||
.expect("rebuild");
|
||||
|
||||
// The named CHECK metadata survived: DROP CONSTRAINT by name resolves.
|
||||
r.block_on(db.alter_drop_constraint(
|
||||
@@ -878,7 +973,9 @@ fn e2e_describe_shows_table_level_constraints() {
|
||||
"events: {events:?}"
|
||||
);
|
||||
|
||||
let desc = r.block_on(db.describe_table("T".to_string())).expect("describe");
|
||||
let desc = r
|
||||
.block_on(db.describe_table("T".to_string()))
|
||||
.expect("describe");
|
||||
assert_eq!(
|
||||
desc.unique_constraints,
|
||||
vec![vec!["a".to_string(), "b".to_string()]],
|
||||
@@ -890,7 +987,9 @@ fn e2e_describe_shows_table_level_constraints() {
|
||||
.map(|c| (c.name.clone(), c.expr.clone()))
|
||||
.collect();
|
||||
assert!(
|
||||
checks.iter().any(|(n, e)| n.is_none() && e.contains("a < b")),
|
||||
checks
|
||||
.iter()
|
||||
.any(|(n, e)| n.is_none() && e.contains("a < b")),
|
||||
"unnamed table CHECK surfaced: {checks:?}"
|
||||
);
|
||||
assert!(
|
||||
@@ -972,8 +1071,14 @@ fn e2e_rename_table_with_rows_csv_follows_and_survives_rebuild() {
|
||||
tables.contains(&"Purchases".to_string()) && !tables.contains(&"Orders".to_string()),
|
||||
"the table is now Purchases, not Orders: {tables:?}"
|
||||
);
|
||||
assert!(csv_path(&project, "Purchases").exists(), "data/Purchases.csv written");
|
||||
assert!(!csv_path(&project, "Orders").exists(), "data/Orders.csv removed");
|
||||
assert!(
|
||||
csv_path(&project, "Purchases").exists(),
|
||||
"data/Purchases.csv written"
|
||||
);
|
||||
assert!(
|
||||
!csv_path(&project, "Orders").exists(),
|
||||
"data/Orders.csv removed"
|
||||
);
|
||||
|
||||
let rows = r
|
||||
.block_on(db.query_data("Purchases".to_string(), None, None))
|
||||
@@ -1052,7 +1157,10 @@ fn e2e_rename_table_with_table_qualified_check_survives_fresh_rebuild() {
|
||||
],
|
||||
Some("i".into()),
|
||||
));
|
||||
assert!(bad_after.is_err(), "the rewritten CHECK enforces after a fresh rebuild");
|
||||
assert!(
|
||||
bad_after.is_err(),
|
||||
"the rewritten CHECK enforces after a fresh rebuild"
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
@@ -1077,7 +1185,9 @@ fn e2e_rename_fk_parent_updates_metadata_and_still_enforces() {
|
||||
);
|
||||
|
||||
// The child's outbound relationship now points at the new parent name.
|
||||
let c = r.block_on(db.describe_table("C".to_string())).expect("describe C");
|
||||
let c = r
|
||||
.block_on(db.describe_table("C".to_string()))
|
||||
.expect("describe C");
|
||||
assert_eq!(c.outbound_relationships.len(), 1);
|
||||
assert_eq!(c.outbound_relationships[0].other_table, "Parent");
|
||||
|
||||
@@ -1129,7 +1239,9 @@ fn e2e_rename_fk_child_updates_metadata_and_still_enforces() {
|
||||
);
|
||||
|
||||
// The parent's inbound relationship now names the renamed child.
|
||||
let p = r.block_on(db.describe_table("P".to_string())).expect("describe P");
|
||||
let p = r
|
||||
.block_on(db.describe_table("P".to_string()))
|
||||
.expect("describe P");
|
||||
assert_eq!(p.inbound_relationships.len(), 1);
|
||||
assert_eq!(p.inbound_relationships[0].other_table, "Child");
|
||||
|
||||
@@ -1168,7 +1280,9 @@ fn e2e_rename_self_referential_table_updates_both_ends() {
|
||||
);
|
||||
|
||||
// Both ends of the self-reference now name `Tree`.
|
||||
let t = r.block_on(db.describe_table("Tree".to_string())).expect("describe Tree");
|
||||
let t = r
|
||||
.block_on(db.describe_table("Tree".to_string()))
|
||||
.expect("describe Tree");
|
||||
assert_eq!(t.outbound_relationships[0].other_table, "Tree");
|
||||
assert_eq!(t.inbound_relationships[0].other_table, "Tree");
|
||||
|
||||
@@ -1216,7 +1330,9 @@ fn e2e_rename_table_keeps_its_index_with_a_stale_name() {
|
||||
"events: {events:?}"
|
||||
);
|
||||
|
||||
let u = r.block_on(db.describe_table("Users".to_string())).expect("describe Users");
|
||||
let u = r
|
||||
.block_on(db.describe_table("Users".to_string()))
|
||||
.expect("describe Users");
|
||||
assert_eq!(u.indexes.len(), 1, "the index followed the rename");
|
||||
assert_eq!(
|
||||
u.indexes[0].name, "T_email_idx",
|
||||
@@ -1226,7 +1342,9 @@ fn e2e_rename_table_keeps_its_index_with_a_stale_name() {
|
||||
|
||||
// Survives a fresh rebuild (recreated from IndexSchema on table Users).
|
||||
let db = fresh_rebuild(db, &project, &r);
|
||||
let u = r.block_on(db.describe_table("Users".to_string())).expect("describe Users");
|
||||
let u = r
|
||||
.block_on(db.describe_table("Users".to_string()))
|
||||
.expect("describe Users");
|
||||
assert_eq!(u.indexes.len(), 1);
|
||||
assert_eq!(u.indexes[0].name, "T_email_idx");
|
||||
}
|
||||
@@ -1248,14 +1366,20 @@ fn e2e_rename_table_is_one_undo_step() {
|
||||
assert!(table_names(&db, &r).contains(&"Purchases".to_string()));
|
||||
|
||||
// One undo reverts the rename.
|
||||
assert!(r.block_on(db.undo()).expect("undo").is_some(), "rename was one undo step");
|
||||
assert!(
|
||||
r.block_on(db.undo()).expect("undo").is_some(),
|
||||
"rename was one undo step"
|
||||
);
|
||||
let tables = table_names(&db, &r);
|
||||
assert!(
|
||||
tables.contains(&"Orders".to_string()) && !tables.contains(&"Purchases".to_string()),
|
||||
"undo restored the old table name: {tables:?}"
|
||||
);
|
||||
assert_eq!(
|
||||
r.block_on(db.query_data("Orders".to_string(), None, None)).expect("query").rows.len(),
|
||||
r.block_on(db.query_data("Orders".to_string(), None, None))
|
||||
.expect("query")
|
||||
.rows
|
||||
.len(),
|
||||
1,
|
||||
"the row is back under the old name"
|
||||
);
|
||||
@@ -1286,19 +1410,23 @@ fn e2e_rename_table_refusals() {
|
||||
r.block_on(run_replay(&db, project.path(), "setup.commands"));
|
||||
|
||||
assert!(
|
||||
r.block_on(db.rename_table("T".into(), "X".into(), Some("rn".into()))).is_err(),
|
||||
r.block_on(db.rename_table("T".into(), "X".into(), Some("rn".into())))
|
||||
.is_err(),
|
||||
"rename to an existing other table is refused"
|
||||
);
|
||||
assert!(
|
||||
r.block_on(db.rename_table("T".into(), "T".into(), Some("rn".into()))).is_err(),
|
||||
r.block_on(db.rename_table("T".into(), "T".into(), Some("rn".into())))
|
||||
.is_err(),
|
||||
"rename to the same name is refused"
|
||||
);
|
||||
assert!(
|
||||
r.block_on(db.rename_table("Ghost".into(), "G".into(), Some("rn".into()))).is_err(),
|
||||
r.block_on(db.rename_table("Ghost".into(), "G".into(), Some("rn".into())))
|
||||
.is_err(),
|
||||
"rename of a non-existent table is refused"
|
||||
);
|
||||
assert!(
|
||||
r.block_on(db.rename_table("T".into(), "__rdbms_evil".into(), Some("rn".into()))).is_err(),
|
||||
r.block_on(db.rename_table("T".into(), "__rdbms_evil".into(), Some("rn".into())))
|
||||
.is_err(),
|
||||
"rename to an internal table name is refused at the executor"
|
||||
);
|
||||
|
||||
@@ -1315,7 +1443,8 @@ fn e2e_rename_table_refusals() {
|
||||
);
|
||||
}
|
||||
assert!(
|
||||
r.block_on(db.rename_table("T".into(), "x".into(), Some("rn".into()))).is_err(),
|
||||
r.block_on(db.rename_table("T".into(), "x".into(), Some("rn".into())))
|
||||
.is_err(),
|
||||
"rename to a name colliding case-insensitively with another table (X) is refused"
|
||||
);
|
||||
|
||||
@@ -1348,7 +1477,10 @@ fn e2e_alter_column_set_not_null_enforced() {
|
||||
.expect("write");
|
||||
let events = r.block_on(run_replay(&db, project.path(), "a.commands"));
|
||||
assert!(
|
||||
matches!(events.last(), Some(AppEvent::ReplayCompleted { count: 4, .. })),
|
||||
matches!(
|
||||
events.last(),
|
||||
Some(AppEvent::ReplayCompleted { count: 4, .. })
|
||||
),
|
||||
"set not null on a clean column succeeds; events: {events:?}"
|
||||
);
|
||||
assert!(
|
||||
@@ -1390,7 +1522,10 @@ fn e2e_alter_column_drop_not_null_allows_nulls() {
|
||||
.expect("write");
|
||||
let events = r.block_on(run_replay(&db, project.path(), "a.commands"));
|
||||
assert!(
|
||||
matches!(events.last(), Some(AppEvent::ReplayCompleted { count: 4, .. })),
|
||||
matches!(
|
||||
events.last(),
|
||||
Some(AppEvent::ReplayCompleted { count: 4, .. })
|
||||
),
|
||||
"events: {events:?}"
|
||||
);
|
||||
r.block_on(db.insert(
|
||||
@@ -1416,7 +1551,10 @@ fn e2e_alter_column_set_default_applies() {
|
||||
.expect("write");
|
||||
let events = r.block_on(run_replay(&db, project.path(), "a.commands"));
|
||||
assert!(
|
||||
matches!(events.last(), Some(AppEvent::ReplayCompleted { count: 3, .. })),
|
||||
matches!(
|
||||
events.last(),
|
||||
Some(AppEvent::ReplayCompleted { count: 3, .. })
|
||||
),
|
||||
"events: {events:?}"
|
||||
);
|
||||
r.block_on(db.insert(
|
||||
@@ -1462,7 +1600,10 @@ fn e2e_alter_column_drop_default_removes_it() {
|
||||
.expect("write");
|
||||
let events = r.block_on(run_replay(&db, project.path(), "a.commands"));
|
||||
assert!(
|
||||
matches!(events.last(), Some(AppEvent::ReplayCompleted { count: 4, .. })),
|
||||
matches!(
|
||||
events.last(),
|
||||
Some(AppEvent::ReplayCompleted { count: 4, .. })
|
||||
),
|
||||
"events: {events:?}"
|
||||
);
|
||||
r.block_on(db.insert(
|
||||
@@ -1499,7 +1640,10 @@ fn e2e_alter_column_set_data_type_converts() {
|
||||
.expect("write");
|
||||
let events = r.block_on(run_replay(&db, project.path(), "a.commands"));
|
||||
assert!(
|
||||
matches!(events.last(), Some(AppEvent::ReplayCompleted { count: 4, .. })),
|
||||
matches!(
|
||||
events.last(),
|
||||
Some(AppEvent::ReplayCompleted { count: 4, .. })
|
||||
),
|
||||
"events: {events:?}"
|
||||
);
|
||||
assert_eq!(
|
||||
|
||||
Reference in New Issue
Block a user