Skip to content

Commit 004131e

Browse files
committed
Refactor inline
1 parent e83706c commit 004131e

File tree

6 files changed

+13
-15
lines changed

6 files changed

+13
-15
lines changed

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -773,7 +773,7 @@ mod tests {
773773
assert_eq!(idx_b.1, vec!["col3".to_string()]);
774774

775775
// Check auto-generated index for col4 (should have name: None)
776-
let idx_col4 = indexes.iter().find(|(n, _)| n == &None).unwrap();
776+
let idx_col4 = indexes.iter().find(|(n, _)| n.is_none()).unwrap();
777777
assert_eq!(idx_col4.1, vec!["col4".to_string()]);
778778
}
779779

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

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -107,10 +107,10 @@ fn single_column_unique_set(constraints: &[TableConstraint]) -> HashSet<String>
107107
fn single_column_index_set(constraints: &[TableConstraint]) -> HashSet<String> {
108108
let mut indexed_cols = HashSet::new();
109109
for constraint in constraints {
110-
if let TableConstraint::Index { columns, .. } = constraint {
111-
if columns.len() == 1 {
112-
indexed_cols.insert(columns[0].clone());
113-
}
110+
if let TableConstraint::Index { columns, .. } = constraint
111+
&& columns.len() == 1
112+
{
113+
indexed_cols.insert(columns[0].clone());
114114
}
115115
}
116116
indexed_cols

crates/vespertide-planner/src/apply.rs

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -177,8 +177,11 @@ pub fn apply_action(
177177
// Clear inline index on columns when removing an index constraint
178178
// Check if this index name was auto-generated for a single column
179179
for col in &mut tbl.columns {
180-
let auto_name =
181-
vespertide_naming::build_index_name(table, &[col.name.clone()], None);
180+
let auto_name = vespertide_naming::build_index_name(
181+
table,
182+
std::slice::from_ref(&col.name),
183+
None,
184+
);
182185
if name.as_ref() == Some(&auto_name) {
183186
col.index = None;
184187
break;

crates/vespertide-planner/src/diff.rs

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -380,11 +380,7 @@ mod tests {
380380
use rstest::rstest;
381381
use vespertide_core::{
382382
ColumnDef, ColumnType, MigrationAction, SimpleColumnType,
383-
schema::{
384-
foreign_key::{ForeignKeyDef, ForeignKeySyntax},
385-
primary_key::PrimaryKeySyntax,
386-
str_or_bool::StrOrBoolOrArray,
387-
},
383+
schema::{primary_key::PrimaryKeySyntax, str_or_bool::StrOrBoolOrArray},
388384
};
389385

390386
fn col(name: &str, ty: ColumnType) -> ColumnDef {
@@ -1684,7 +1680,7 @@ mod tests {
16841680
}
16851681

16861682
mod index {
1687-
use insta::{Snapshot, assert_debug_snapshot};
1683+
use insta::assert_debug_snapshot;
16881684

16891685
use super::*;
16901686

crates/vespertide-planner/src/snapshots/vespertide_planner__diff__tests__index__create_table_with_inline_index-2.snap.new renamed to crates/vespertide-planner/src/snapshots/vespertide_planner__diff__tests__index__create_table_with_inline_index-2.snap

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
---
22
source: crates/vespertide-planner/src/diff.rs
3-
assertion_line: 1723
43
expression: plan.actions
54
---
65
[

crates/vespertide-query/src/sql/create_table.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -228,7 +228,7 @@ pub fn build_create_table(
228228
} = constraint
229229
{
230230
// Always generate a proper name: ix_{table}_{key} or ix_{table}_{columns}
231-
let index_name = super::helpers::build_index_name(table, &index_cols, name.as_deref());
231+
let index_name = super::helpers::build_index_name(table, index_cols, name.as_deref());
232232
let mut idx = Index::create()
233233
.table(Alias::new(table))
234234
.name(&index_name)

0 commit comments

Comments
 (0)