Skip to content

Commit c85fa90

Browse files
authored
Merge pull request #28 from dev-five-git/exporter-issue
Exporter issue
2 parents 0c788ee + ee8467d commit c85fa90

File tree

78 files changed

+4561
-1287
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

78 files changed

+4561
-1287
lines changed
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
{"changes":{"crates/vespertide-cli/Cargo.toml":"Patch","crates/vespertide-core/Cargo.toml":"Patch","crates/vespertide-exporter/Cargo.toml":"Patch","crates/vespertide-macro/Cargo.toml":"Patch","crates/vespertide-planner/Cargo.toml":"Patch","crates/vespertide/Cargo.toml":"Patch","crates/vespertide-query/Cargo.toml":"Patch","crates/vespertide-loader/Cargo.toml":"Patch","crates/vespertide-config/Cargo.toml":"Patch"},"note":"Add column validation","date":"2025-12-18T15:48:46.157103400Z"}
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
{"changes":{"crates/vespertide-cli/Cargo.toml":"Patch","crates/vespertide-planner/Cargo.toml":"Patch","crates/vespertide-macro/Cargo.toml":"Patch","crates/vespertide-loader/Cargo.toml":"Patch","crates/vespertide-core/Cargo.toml":"Patch","crates/vespertide-query/Cargo.toml":"Patch","crates/vespertide-config/Cargo.toml":"Patch","crates/vespertide/Cargo.toml":"Patch","crates/vespertide-exporter/Cargo.toml":"Patch"},"note":"Implement num_enum","date":"2025-12-18T15:48:35.861293400Z"}

.gitignore

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1-
/target
2-
local.db
3-
settings.local.json
1+
/target
2+
local.db
3+
settings.local.json
4+
coverage

Cargo.lock

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

crates/vespertide-cli/src/commands/diff.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -248,7 +248,7 @@ mod tests {
248248
#[case(
249249
MigrationAction::AddColumn {
250250
table: "users".into(),
251-
column: ColumnDef {
251+
column: Box::new(ColumnDef {
252252
name: "name".into(),
253253
r#type: ColumnType::Simple(SimpleColumnType::Text),
254254
nullable: true,
@@ -258,7 +258,7 @@ mod tests {
258258
unique: None,
259259
index: None,
260260
foreign_key: None,
261-
},
261+
}),
262262
fill_with: None,
263263
},
264264
format!("{} {}.{}", "Add column:".bright_green(), "users".bright_cyan(), "name".bright_cyan().bold())

crates/vespertide-cli/src/commands/export.rs

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ use anyhow::{Context, Result};
77
use clap::ValueEnum;
88
use vespertide_config::VespertideConfig;
99
use vespertide_core::TableDef;
10-
use vespertide_exporter::{Orm, render_entity};
10+
use vespertide_exporter::{Orm, render_entity_with_schema};
1111

1212
use crate::utils::load_config;
1313

@@ -51,8 +51,12 @@ pub fn cmd_export(orm: OrmArg, export_dir: Option<PathBuf>) -> Result<()> {
5151

5252
let orm_kind: Orm = orm.into();
5353

54+
// Extract all tables for schema context (used for FK chain resolution)
55+
let all_tables: Vec<TableDef> = normalized_models.iter().map(|(t, _)| t.clone()).collect();
56+
5457
for (table, rel_path) in &normalized_models {
55-
let code = render_entity(orm_kind, table).map_err(|e| anyhow::anyhow!(e))?;
58+
let code = render_entity_with_schema(orm_kind, table, &all_tables)
59+
.map_err(|e| anyhow::anyhow!(e))?;
5660
let out_path = build_output_path(&target_root, rel_path, orm_kind);
5761
if let Some(parent) = out_path.parent() {
5862
fs::create_dir_all(parent)

crates/vespertide-cli/src/commands/sql.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -431,7 +431,7 @@ mod tests {
431431
version: 1,
432432
actions: vec![MigrationAction::AddColumn {
433433
table: "users".into(),
434-
column: ColumnDef {
434+
column: Box::new(ColumnDef {
435435
name: "nickname".into(),
436436
r#type: ColumnType::Simple(SimpleColumnType::Text),
437437
nullable: false,
@@ -441,7 +441,7 @@ mod tests {
441441
unique: None,
442442
index: None,
443443
foreign_key: None,
444-
},
444+
}),
445445
fill_with: Some("default".into()),
446446
}],
447447
};

crates/vespertide-core/src/action.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ pub enum MigrationAction {
2828
},
2929
AddColumn {
3030
table: TableName,
31-
column: ColumnDef,
31+
column: Box<ColumnDef>,
3232
/// Optional fill value to backfill existing rows when adding NOT NULL without default.
3333
fill_with: Option<String>,
3434
},
@@ -194,7 +194,7 @@ mod tests {
194194
#[case::add_column(
195195
MigrationAction::AddColumn {
196196
table: "users".into(),
197-
column: default_column(),
197+
column: Box::new(default_column()),
198198
fill_with: None,
199199
},
200200
"AddColumn: users.email"

crates/vespertide-core/src/lib.rs

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,11 @@
1-
pub mod action;
2-
pub mod migration;
3-
pub mod schema;
4-
5-
pub use action::{MigrationAction, MigrationPlan};
6-
pub use migration::{MigrationError, MigrationOptions};
7-
pub use schema::{
8-
ColumnDef, ColumnName, ColumnType, ComplexColumnType, IndexDef, IndexName, ReferenceAction,
9-
SimpleColumnType, StrOrBoolOrArray, TableConstraint, TableDef, TableName, TableValidationError,
10-
};
1+
pub mod action;
2+
pub mod migration;
3+
pub mod schema;
4+
5+
pub use action::{MigrationAction, MigrationPlan};
6+
pub use migration::{MigrationError, MigrationOptions};
7+
pub use schema::{
8+
ColumnDef, ColumnName, ColumnType, ComplexColumnType, EnumValues, IndexDef, IndexName,
9+
NumValue, ReferenceAction, SimpleColumnType, StrOrBoolOrArray, TableConstraint, TableDef,
10+
TableName, TableValidationError,
11+
};

0 commit comments

Comments
 (0)