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:
+51
-28
@@ -9,7 +9,7 @@
|
||||
|
||||
use rdbms_playground::db::Database;
|
||||
use rdbms_playground::dsl::{
|
||||
parse_command, ColumnSpec, Command, ReferentialAction, SqlForeignKey, Type, Value,
|
||||
ColumnSpec, Command, ReferentialAction, SqlForeignKey, Type, Value, parse_command,
|
||||
};
|
||||
use rdbms_playground::persistence::Persistence;
|
||||
use rdbms_playground::project;
|
||||
@@ -18,10 +18,8 @@ use rdbms_playground::project;
|
||||
|
||||
#[test]
|
||||
fn parenthesized_compound_endpoint_parses_to_column_lists() {
|
||||
let cmd = parse_command(
|
||||
"add 1:n relationship from Parent.(a, b) to Child.(x, y)",
|
||||
)
|
||||
.expect("parses");
|
||||
let cmd =
|
||||
parse_command("add 1:n relationship from Parent.(a, b) to Child.(x, y)").expect("parses");
|
||||
match cmd {
|
||||
Command::AddRelationship {
|
||||
parent_table,
|
||||
@@ -41,8 +39,7 @@ fn parenthesized_compound_endpoint_parses_to_column_lists() {
|
||||
|
||||
#[test]
|
||||
fn single_column_endpoint_still_parses_unparenthesized() {
|
||||
let cmd = parse_command("add 1:n relationship from Parent.id to Child.pid")
|
||||
.expect("parses");
|
||||
let cmd = parse_command("add 1:n relationship from Parent.id to Child.pid").expect("parses");
|
||||
match cmd {
|
||||
Command::AddRelationship {
|
||||
parent_columns,
|
||||
@@ -148,7 +145,10 @@ fn sql_create_table_compound_fk_executes_and_enforces() {
|
||||
db.insert(
|
||||
"Region".to_string(),
|
||||
Some(vec!["country".to_string(), "code".to_string()]),
|
||||
vec![Value::Number("1".to_string()), Value::Number("10".to_string())],
|
||||
vec![
|
||||
Value::Number("1".to_string()),
|
||||
Value::Number("10".to_string()),
|
||||
],
|
||||
None,
|
||||
)
|
||||
.await
|
||||
@@ -157,7 +157,10 @@ fn sql_create_table_compound_fk_executes_and_enforces() {
|
||||
.insert(
|
||||
"City".to_string(),
|
||||
Some(vec!["country".to_string(), "region_code".to_string()]),
|
||||
vec![Value::Number("9".to_string()), Value::Number("9".to_string())],
|
||||
vec![
|
||||
Value::Number("9".to_string()),
|
||||
Value::Number("9".to_string()),
|
||||
],
|
||||
None,
|
||||
)
|
||||
.await;
|
||||
@@ -176,8 +179,7 @@ fn rt() -> tokio::runtime::Runtime {
|
||||
|
||||
fn open_project_db() -> (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 persistence = Persistence::new(project.path().to_path_buf());
|
||||
let db = Database::open_with_persistence(project.db_path(), persistence)
|
||||
.expect("open db with persistence");
|
||||
@@ -241,7 +243,10 @@ fn compound_fk_declares_enforces_and_round_trips() {
|
||||
db.insert(
|
||||
"Region".to_string(),
|
||||
Some(vec!["country".to_string(), "code".to_string()]),
|
||||
vec![Value::Number("1".to_string()), Value::Number("10".to_string())],
|
||||
vec![
|
||||
Value::Number("1".to_string()),
|
||||
Value::Number("10".to_string()),
|
||||
],
|
||||
None,
|
||||
)
|
||||
.await
|
||||
@@ -253,7 +258,11 @@ fn compound_fk_declares_enforces_and_round_trips() {
|
||||
"region_code".to_string(),
|
||||
"name".to_string(),
|
||||
]),
|
||||
vec![Value::Number("1".to_string()), Value::Number("10".to_string()), Value::Text("Metropolis".to_string())],
|
||||
vec![
|
||||
Value::Number("1".to_string()),
|
||||
Value::Number("10".to_string()),
|
||||
Value::Text("Metropolis".to_string()),
|
||||
],
|
||||
None,
|
||||
)
|
||||
.await
|
||||
@@ -266,7 +275,11 @@ fn compound_fk_declares_enforces_and_round_trips() {
|
||||
"region_code".to_string(),
|
||||
"name".to_string(),
|
||||
]),
|
||||
vec![Value::Number("9".to_string()), Value::Number("9".to_string()), Value::Text("Nowhere".to_string())],
|
||||
vec![
|
||||
Value::Number("9".to_string()),
|
||||
Value::Number("9".to_string()),
|
||||
Value::Text("Nowhere".to_string()),
|
||||
],
|
||||
None,
|
||||
)
|
||||
.await;
|
||||
@@ -360,7 +373,10 @@ fn compound_fk_arity_mismatch_is_refused() {
|
||||
None,
|
||||
)
|
||||
.await;
|
||||
assert!(err.is_err(), "mismatched child/parent arity must be refused");
|
||||
assert!(
|
||||
err.is_err(),
|
||||
"mismatched child/parent arity must be refused"
|
||||
);
|
||||
});
|
||||
}
|
||||
|
||||
@@ -386,10 +402,8 @@ fn inline_fk_referencing_compound_pk_points_at_table_level_form() {
|
||||
.expect("create Region");
|
||||
|
||||
// Parse the inline form so the `inline` flag is set by the grammar.
|
||||
let cmd = parse_command(
|
||||
"create table City (country int references Region(country, code))",
|
||||
)
|
||||
.expect("parses");
|
||||
let cmd = parse_command("create table City (country int references Region(country, code))")
|
||||
.expect("parses");
|
||||
let Command::SqlCreateTable {
|
||||
name,
|
||||
columns,
|
||||
@@ -465,7 +479,10 @@ fn compound_fk_type_mismatch_per_pair_is_refused() {
|
||||
None,
|
||||
)
|
||||
.await;
|
||||
assert!(err.is_err(), "a type-incompatible column pair must be refused");
|
||||
assert!(
|
||||
err.is_err(),
|
||||
"a type-incompatible column pair must be refused"
|
||||
);
|
||||
});
|
||||
}
|
||||
|
||||
@@ -478,11 +495,8 @@ fn compound_fk_survives_rebuild_from_text() {
|
||||
let path = project.path().to_path_buf();
|
||||
let rt = rt();
|
||||
{
|
||||
let db = Database::open_with_persistence(
|
||||
project.db_path(),
|
||||
Persistence::new(path.clone()),
|
||||
)
|
||||
.expect("open db");
|
||||
let db = Database::open_with_persistence(project.db_path(), Persistence::new(path.clone()))
|
||||
.expect("open db");
|
||||
rt.block_on(async {
|
||||
seed_compound(&db).await;
|
||||
db.add_relationship(
|
||||
@@ -512,7 +526,10 @@ fn compound_fk_survives_rebuild_from_text() {
|
||||
db.insert(
|
||||
"Region".to_string(),
|
||||
Some(vec!["country".to_string(), "code".to_string()]),
|
||||
vec![Value::Number("1".to_string()), Value::Number("10".to_string())],
|
||||
vec![
|
||||
Value::Number("1".to_string()),
|
||||
Value::Number("10".to_string()),
|
||||
],
|
||||
None,
|
||||
)
|
||||
.await
|
||||
@@ -521,11 +538,17 @@ fn compound_fk_survives_rebuild_from_text() {
|
||||
.insert(
|
||||
"City".to_string(),
|
||||
Some(vec!["country".to_string(), "region_code".to_string()]),
|
||||
vec![Value::Number("9".to_string()), Value::Number("9".to_string())],
|
||||
vec![
|
||||
Value::Number("9".to_string()),
|
||||
Value::Number("9".to_string()),
|
||||
],
|
||||
None,
|
||||
)
|
||||
.await;
|
||||
assert!(bad.is_err(), "compound FK still enforced after rebuild from text");
|
||||
assert!(
|
||||
bad.is_err(),
|
||||
"compound FK still enforced after rebuild from text"
|
||||
);
|
||||
// Endpoints survived the round-trip intact.
|
||||
let city = db.describe_table("City".to_string()).await.unwrap();
|
||||
assert_eq!(
|
||||
|
||||
Reference in New Issue
Block a user