Skip to content

Commit 3bc85fb

Browse files
authored
Merge pull request #98 from dev-five-git/conditional-serde
Change default serde
2 parents 9fdfff2 + 4d68f80 commit 3bc85fb

31 files changed

Lines changed: 42 additions & 65 deletions

File tree

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
{"changes":{"crates/vespertide-core/Cargo.toml":"Patch","crates/vespertide-cli/Cargo.toml":"Patch","crates/vespertide-macro/Cargo.toml":"Patch","crates/vespertide-naming/Cargo.toml":"Patch","crates/vespertide-planner/Cargo.toml":"Patch","crates/vespertide-query/Cargo.toml":"Patch","crates/vespertide/Cargo.toml":"Patch","crates/vespertide-config/Cargo.toml":"Patch","crates/vespertide-loader/Cargo.toml":"Patch","crates/vespertide-exporter/Cargo.toml":"Patch"},"note":"Change Model default derive","date":"2026-02-03T13:21:35.204526200Z"}

crates/vespertide-exporter/src/seaorm/mod.rs

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -85,9 +85,19 @@ pub fn render_entity_with_config(
8585
let unique_columns = single_column_unique_set(&table.constraints);
8686
let indexed_columns = single_column_index_set(&table.constraints);
8787

88+
// Check if any columns use enum types (enums derive Serialize/Deserialize)
89+
let has_enums = table.columns.iter().any(|c| {
90+
matches!(
91+
c.r#type,
92+
ColumnType::Complex(ComplexColumnType::Enum { .. })
93+
)
94+
});
95+
8896
let mut lines: Vec<String> = Vec::new();
8997
lines.push("use sea_orm::entity::prelude::*;".into());
90-
lines.push("use serde::{Deserialize, Serialize};".into());
98+
if has_enums {
99+
lines.push("use serde::{Deserialize, Serialize};".into());
100+
}
91101
lines.push(String::new());
92102

93103
// Generate Enum definitions first
@@ -103,15 +113,7 @@ pub fn render_entity_with_config(
103113
}
104114

105115
// Build model derive line with optional extra derives
106-
let mut model_derives = vec![
107-
"Clone",
108-
"Debug",
109-
"PartialEq",
110-
"Eq",
111-
"DeriveEntityModel",
112-
"Serialize",
113-
"Deserialize",
114-
];
116+
let mut model_derives = vec!["Clone", "Debug", "PartialEq", "Eq", "DeriveEntityModel"];
115117
let extra_model_derives: Vec<&str> = config
116118
.extra_model_derives()
117119
.iter()

crates/vespertide-exporter/src/seaorm/snapshots/vespertide_exporter__seaorm__tests__integer_enum_default_value_snapshots@1.snap

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ pub enum TaskStatus {
1515
}
1616

1717
#[sea_orm::model]
18-
#[derive(Clone, Debug, PartialEq, Eq, DeriveEntityModel, Serialize, Deserialize)]
18+
#[derive(Clone, Debug, PartialEq, Eq, DeriveEntityModel)]
1919
#[sea_orm(table_name = "tasks")]
2020
pub struct Model {
2121
#[sea_orm(primary_key)]

crates/vespertide-exporter/src/seaorm/snapshots/vespertide_exporter__seaorm__tests__integer_enum_default_value_snapshots@pending_status.snap

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ pub enum TaskStatus {
1515
}
1616

1717
#[sea_orm::model]
18-
#[derive(Clone, Debug, PartialEq, Eq, DeriveEntityModel, Serialize, Deserialize)]
18+
#[derive(Clone, Debug, PartialEq, Eq, DeriveEntityModel)]
1919
#[sea_orm(table_name = "tasks")]
2020
pub struct Model {
2121
#[sea_orm(primary_key)]

crates/vespertide-exporter/src/seaorm/snapshots/vespertide_exporter__seaorm__tests__render_entity_snapshots@params_basic_single_pk.snap

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,9 @@ source: crates/vespertide-exporter/src/seaorm/mod.rs
33
expression: rendered
44
---
55
use sea_orm::entity::prelude::*;
6-
use serde::{Deserialize, Serialize};
76

87
#[sea_orm::model]
9-
#[derive(Clone, Debug, PartialEq, Eq, DeriveEntityModel, Serialize, Deserialize)]
8+
#[derive(Clone, Debug, PartialEq, Eq, DeriveEntityModel)]
109
#[sea_orm(table_name = "users")]
1110
pub struct Model {
1211
#[sea_orm(primary_key)]

crates/vespertide-exporter/src/seaorm/snapshots/vespertide_exporter__seaorm__tests__render_entity_snapshots@params_composite_pk.snap

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,9 @@ source: crates/vespertide-exporter/src/seaorm/mod.rs
33
expression: rendered
44
---
55
use sea_orm::entity::prelude::*;
6-
use serde::{Deserialize, Serialize};
76

87
#[sea_orm::model]
9-
#[derive(Clone, Debug, PartialEq, Eq, DeriveEntityModel, Serialize, Deserialize)]
8+
#[derive(Clone, Debug, PartialEq, Eq, DeriveEntityModel)]
109
#[sea_orm(table_name = "accounts")]
1110
pub struct Model {
1211
#[sea_orm(primary_key, auto_increment = false)]

crates/vespertide-exporter/src/seaorm/snapshots/vespertide_exporter__seaorm__tests__render_entity_snapshots@params_enum_multiple_columns.snap

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ pub enum AvailabilityStatus {
3030
}
3131

3232
#[sea_orm::model]
33-
#[derive(Clone, Debug, PartialEq, Eq, DeriveEntityModel, Serialize, Deserialize)]
33+
#[derive(Clone, Debug, PartialEq, Eq, DeriveEntityModel)]
3434
#[sea_orm(table_name = "products")]
3535
pub struct Model {
3636
#[sea_orm(primary_key)]

crates/vespertide-exporter/src/seaorm/snapshots/vespertide_exporter__seaorm__tests__render_entity_snapshots@params_enum_nullable.snap

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ pub enum TaskPriority {
2020
}
2121

2222
#[sea_orm::model]
23-
#[derive(Clone, Debug, PartialEq, Eq, DeriveEntityModel, Serialize, Deserialize)]
23+
#[derive(Clone, Debug, PartialEq, Eq, DeriveEntityModel)]
2424
#[sea_orm(table_name = "tasks")]
2525
pub struct Model {
2626
#[sea_orm(primary_key)]

crates/vespertide-exporter/src/seaorm/snapshots/vespertide_exporter__seaorm__tests__render_entity_snapshots@params_enum_shared.snap

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ pub enum DocStatus {
1818
}
1919

2020
#[sea_orm::model]
21-
#[derive(Clone, Debug, PartialEq, Eq, DeriveEntityModel, Serialize, Deserialize)]
21+
#[derive(Clone, Debug, PartialEq, Eq, DeriveEntityModel)]
2222
#[sea_orm(table_name = "documents")]
2323
pub struct Model {
2424
#[sea_orm(primary_key)]

crates/vespertide-exporter/src/seaorm/snapshots/vespertide_exporter__seaorm__tests__render_entity_snapshots@params_enum_special_values.snap

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ pub enum EventSeverity {
2020
}
2121

2222
#[sea_orm::model]
23-
#[derive(Clone, Debug, PartialEq, Eq, DeriveEntityModel, Serialize, Deserialize)]
23+
#[derive(Clone, Debug, PartialEq, Eq, DeriveEntityModel)]
2424
#[sea_orm(table_name = "events")]
2525
pub struct Model {
2626
#[sea_orm(primary_key)]

0 commit comments

Comments
 (0)