Skip to content

Commit deae03f

Browse files
authored
Merge pull request #99 from dev-five-git/add-vespera-schema
Add vespera schema_type
2 parents 562775a + 799dd62 commit deae03f

34 files changed

Lines changed: 71 additions & 11 deletions

File tree

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
{"changes":{"crates/vespertide-config/Cargo.toml":"Patch","crates/vespertide-core/Cargo.toml":"Patch","crates/vespertide-planner/Cargo.toml":"Patch","crates/vespertide-query/Cargo.toml":"Patch","crates/vespertide-macro/Cargo.toml":"Patch","crates/vespertide-naming/Cargo.toml":"Patch","crates/vespertide/Cargo.toml":"Patch","crates/vespertide-loader/Cargo.toml":"Patch","crates/vespertide-exporter/Cargo.toml":"Patch","crates/vespertide-cli/Cargo.toml":"Patch"},"note":"Add vespera schema_type","date":"2026-02-03T17:13:06.154567800Z"}

Cargo.lock

Lines changed: 10 additions & 10 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

crates/vespertide-config/src/config.rs

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,10 @@ pub struct SeaOrmConfig {
2626
/// Default: `Camel` (generates `#[serde(rename_all = "camelCase")]`)
2727
#[serde(default = "default_enum_naming_case")]
2828
pub enum_naming_case: NameCase,
29+
/// Generate `vespera::schema_type!` macro invocation for each entity.
30+
/// Default: `true`
31+
#[serde(default = "default_vespera_schema_type")]
32+
pub vespera_schema_type: bool,
2933
}
3034

3135
fn default_extra_enum_derives() -> Vec<String> {
@@ -36,12 +40,17 @@ fn default_enum_naming_case() -> NameCase {
3640
NameCase::Camel
3741
}
3842

43+
fn default_vespera_schema_type() -> bool {
44+
true
45+
}
46+
3947
impl Default for SeaOrmConfig {
4048
fn default() -> Self {
4149
Self {
4250
extra_enum_derives: default_extra_enum_derives(),
4351
extra_model_derives: Vec::new(),
4452
enum_naming_case: default_enum_naming_case(),
53+
vespera_schema_type: default_vespera_schema_type(),
4554
}
4655
}
4756
}
@@ -61,6 +70,11 @@ impl SeaOrmConfig {
6170
pub fn enum_naming_case(&self) -> NameCase {
6271
self.enum_naming_case
6372
}
73+
74+
/// Whether to generate `vespera::schema_type!` macro invocation for each entity.
75+
pub fn vespera_schema_type(&self) -> bool {
76+
self.vespera_schema_type
77+
}
6478
}
6579

6680
/// Top-level vespertide configuration.
@@ -192,6 +206,7 @@ mod tests {
192206
vec!["vespera::Schema".to_string()]
193207
);
194208
assert!(config.seaorm.extra_model_derives.is_empty());
209+
assert!(config.seaorm.vespera_schema_type);
195210
assert_eq!(config.prefix, "");
196211
}
197212

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

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -156,6 +156,15 @@ pub fn render_entity_with_config(
156156
lines.push(String::new());
157157
render_indexes(&mut lines, &table.constraints);
158158

159+
// Generate vespera::schema_type! macro if enabled
160+
if config.vespera_schema_type() {
161+
let pascal_name = to_pascal_case(&table.name);
162+
lines.push(format!(
163+
"vespera::schema_type!(Schema from Model, name = \"{}Schema\");",
164+
pascal_name
165+
));
166+
}
167+
159168
lines.push("impl ActiveModelBehavior for ActiveModel {}".into());
160169

161170
lines.push(String::new());

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,4 +24,5 @@ pub struct Model {
2424
pub status: TaskStatus,
2525
}
2626

27+
vespera::schema_type!(Schema from Model, name = "TasksSchema");
2728
impl ActiveModelBehavior for ActiveModel {}

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,4 +24,5 @@ pub struct Model {
2424
pub status: TaskStatus,
2525
}
2626

27+
vespera::schema_type!(Schema from Model, name = "TasksSchema");
2728
impl ActiveModelBehavior for ActiveModel {}

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,4 +13,5 @@ pub struct Model {
1313
pub display_name: Option<String>,
1414
}
1515

16+
vespera::schema_type!(Schema from Model, name = "UsersSchema");
1617
impl ActiveModelBehavior for ActiveModel {}

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,4 +14,5 @@ pub struct Model {
1414
pub tenant_id: i64,
1515
}
1616

17+
vespera::schema_type!(Schema from Model, name = "AccountsSchema");
1718
impl ActiveModelBehavior for ActiveModel {}

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,4 +39,5 @@ pub struct Model {
3939
pub availability: AvailabilityStatus,
4040
}
4141

42+
vespera::schema_type!(Schema from Model, name = "ProductsSchema");
4243
impl ActiveModelBehavior for ActiveModel {}

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,4 +28,5 @@ pub struct Model {
2828
pub priority: Option<TaskPriority>,
2929
}
3030

31+
vespera::schema_type!(Schema from Model, name = "TasksSchema");
3132
impl ActiveModelBehavior for ActiveModel {}

0 commit comments

Comments
 (0)