Skip to content

Commit 5fb4e3b

Browse files
committed
Fix field name
1 parent 2d7b80c commit 5fb4e3b

File tree

7 files changed

+25
-17
lines changed

7 files changed

+25
-17
lines changed

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

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,8 +42,12 @@ pub fn cmd_new(name: String, format: ModelFormat) -> Result<()> {
4242
}
4343

4444
fn schema_url_for(format: ModelFormat) -> String {
45+
// If not set, default to public raw GitHub schema location.
46+
// Users can override via VESP_SCHEMA_BASE_URL.
4547
let base = std::env::var("VESP_SCHEMA_BASE_URL").ok();
46-
let base = base.as_deref().unwrap_or("./schemas");
48+
let base = base.as_deref().unwrap_or(
49+
"https://raw.githubusercontent.com/dev-five-git/vespertide/refs/heads/main/schemas",
50+
);
4751
let base = base.trim_end_matches('/');
4852
match format {
4953
ModelFormat::Json => format!("{}/model.schema.json", base),

crates/vespertide-core/src/schema/column.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ use crate::schema::names::ColumnName;
77
#[serde(rename_all = "camelCase")]
88
pub struct ColumnDef {
99
pub name: ColumnName,
10-
pub data_type: ColumnType,
10+
pub r#type: ColumnType,
1111
pub nullable: bool,
1212
pub default: Option<String>,
1313
}

crates/vespertide-planner/src/lib.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -92,11 +92,11 @@ pub fn diff_schemas(from: &[TableDef], to: &[TableDef]) -> Result<MigrationPlan,
9292
// Modified columns
9393
for (col, to_def) in &to_cols {
9494
if let Some(from_def) = from_cols.get(col) {
95-
if from_def.data_type != to_def.data_type {
95+
if from_def.r#type != to_def.r#type {
9696
actions.push(MigrationAction::ModifyColumnType {
9797
table: (*name).to_string(),
9898
column: (*col).to_string(),
99-
new_type: to_def.data_type.clone(),
99+
new_type: to_def.r#type.clone(),
100100
});
101101
}
102102
}
@@ -259,7 +259,7 @@ pub fn apply_action(
259259
.iter_mut()
260260
.find(|c| c.name == *column)
261261
.ok_or_else(|| PlannerError::ColumnNotFound(table.clone(), column.clone()))?;
262-
col.data_type = new_type.clone();
262+
col.r#type = new_type.clone();
263263
Ok(())
264264
}
265265
MigrationAction::AddIndex { table, index } => {
@@ -380,7 +380,7 @@ mod tests {
380380
fn col(name: &str, ty: ColumnType) -> ColumnDef {
381381
ColumnDef {
382382
name: name.to_string(),
383-
data_type: ty,
383+
r#type: ty,
384384
nullable: true,
385385
default: None,
386386
}

crates/vespertide-query/src/lib.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -220,7 +220,7 @@ fn create_table_sql(
220220

221221
fn column_def_sql(column: &ColumnDef, binds: &mut Vec<String>) -> String {
222222
let name = bind(binds, &column.name);
223-
let mut parts = vec![format!("{name} {}", column_type_sql(&column.data_type))];
223+
let mut parts = vec![format!("{name} {}", column_type_sql(&column.r#type))];
224224
if !column.nullable {
225225
parts.push("NOT NULL".into());
226226
}

examples/app/models/user.json

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,10 @@
11
{
2-
"$schema": "./schemas/model.schema.json",
3-
"columns": [],
2+
"$schema": "https://raw.githubusercontent.com/dev-five-git/vespertide/refs/heads/main/schemas/model.schema.json",
3+
"columns": [{
4+
"name": "aa",
5+
"type": "Integer",
6+
"nullable": false
7+
}],
48
"constraints": [],
59
"indexes": [],
610
"name": "user"

schemas/migration.schema.json

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -29,9 +29,6 @@
2929
"ColumnDef": {
3030
"type": "object",
3131
"properties": {
32-
"dataType": {
33-
"$ref": "#/$defs/ColumnType"
34-
},
3532
"default": {
3633
"type": [
3734
"string",
@@ -43,11 +40,14 @@
4340
},
4441
"nullable": {
4542
"type": "boolean"
43+
},
44+
"type": {
45+
"$ref": "#/$defs/ColumnType"
4646
}
4747
},
4848
"required": [
4949
"name",
50-
"dataType",
50+
"type",
5151
"nullable"
5252
]
5353
},

schemas/model.schema.json

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -35,9 +35,6 @@
3535
"ColumnDef": {
3636
"type": "object",
3737
"properties": {
38-
"dataType": {
39-
"$ref": "#/$defs/ColumnType"
40-
},
4138
"default": {
4239
"type": [
4340
"string",
@@ -49,11 +46,14 @@
4946
},
5047
"nullable": {
5148
"type": "boolean"
49+
},
50+
"type": {
51+
"$ref": "#/$defs/ColumnType"
5252
}
5353
},
5454
"required": [
5555
"name",
56-
"dataType",
56+
"type",
5757
"nullable"
5858
]
5959
},

0 commit comments

Comments
 (0)