Skip to content

Commit c769141

Browse files
committed
refactor: replace format! calls with to_string() method
Replace format!("{}", expr) and format!("{:?}", a) with direct to_string() calls for better performance and code clarity in schema parsing logic. Signed-off-by: Svetlin Ralchev <iamralch@users.noreply.github.com>
1 parent e6b451e commit c769141

1 file changed

Lines changed: 7 additions & 7 deletions

File tree

src/schema.rs

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -139,7 +139,7 @@ impl SchemaDef {
139139
// Extract default value if present
140140
let default = column.options.iter().find_map(|opt| {
141141
if let sqlparser::ast::ColumnOption::Default(expr) = &opt.option {
142-
Some(format!("{}", expr))
142+
Some(expr.to_string())
143143
} else {
144144
None
145145
}
@@ -181,8 +181,8 @@ impl SchemaDef {
181181
.map(|c| c.to_string())
182182
.collect(),
183183
name: option.name.as_ref().map(|n| n.to_string()),
184-
on_delete: on_delete.as_ref().map(|a| format!("{:?}", a)),
185-
on_update: on_update.as_ref().map(|a| format!("{:?}", a)),
184+
on_delete: on_delete.as_ref().map(|a| a.to_string()),
185+
on_update: on_update.as_ref().map(|a| a.to_string()),
186186
});
187187
}
188188
_ => {}
@@ -216,8 +216,8 @@ impl SchemaDef {
216216
.map(|c| c.to_string())
217217
.collect(),
218218
name: name.map(|n| n.to_string()),
219-
on_delete: on_delete.as_ref().map(|a| format!("{:?}", a)),
220-
on_update: on_update.as_ref().map(|a| format!("{:?}", a)),
219+
on_delete: on_delete.as_ref().map(|a| a.to_string()),
220+
on_update: on_update.as_ref().map(|a| a.to_string()),
221221
});
222222
}
223223
TableConstraint::Unique {
@@ -304,8 +304,8 @@ impl SchemaDef {
304304
.map(|c| c.to_string())
305305
.collect(),
306306
name: name.map(|n| n.to_string()),
307-
on_delete: on_delete.as_ref().map(|a| format!("{:?}", a)),
308-
on_update: on_update.as_ref().map(|a| format!("{:?}", a)),
307+
on_delete: on_delete.as_ref().map(|a| a.to_string()),
308+
on_update: on_update.as_ref().map(|a| a.to_string()),
309309
});
310310
}
311311
_ => {}

0 commit comments

Comments
 (0)