Skip to content

Commit 0fd7dfd

Browse files
committed
[fix] clippy errors.
1 parent 92d81f2 commit 0fd7dfd

File tree

6 files changed

+22
-22
lines changed

6 files changed

+22
-22
lines changed

diesel_cli/src/infer_schema_internals/data_structures.rs

+7-7
Original file line numberDiff line numberDiff line change
@@ -162,8 +162,8 @@ impl ForeignKeyConstraint {
162162

163163
#[derive(Debug, Eq, PartialEq, Copy, Clone)]
164164
pub enum SupportedColumnStructures {
165-
VIEW,
166-
TABLE,
165+
View,
166+
Table,
167167
}
168168

169169
#[derive(Debug)]
@@ -198,8 +198,8 @@ impl ColumnData {
198198
impl Display for SupportedColumnStructures {
199199
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
200200
let format = match self {
201-
Self::TABLE => "BASE TABLE",
202-
Self::VIEW => "VIEW",
201+
Self::Table => "BASE TABLE",
202+
Self::View => "VIEW",
203203
};
204204
write!(f, "{format}")
205205
}
@@ -209,8 +209,8 @@ impl FromStr for SupportedColumnStructures {
209209
type Err = ();
210210
fn from_str(s: &str) -> Result<Self, Self::Err> {
211211
match s {
212-
"BASE TABLE" => Ok(Self::TABLE),
213-
"VIEW" => Ok(Self::VIEW),
212+
"BASE TABLE" => Ok(Self::Table),
213+
"VIEW" => Ok(Self::View),
214214
_ => unreachable!("This should never happen. Read {s}"),
215215
}
216216
}
@@ -224,6 +224,6 @@ impl SupportedColumnStructures {
224224
.collect()
225225
}
226226
pub fn all() -> Vec<SupportedColumnStructures> {
227-
vec![Self::VIEW, Self::TABLE]
227+
vec![Self::View, Self::Table]
228228
}
229229
}

diesel_cli/src/infer_schema_internals/inference.rs

+6-6
Original file line numberDiff line numberDiff line change
@@ -130,11 +130,11 @@ pub fn load_table_names(
130130
}
131131

132132
pub fn filter_column_structure(
133-
table_names: &Vec<(SupportedColumnStructures, TableName)>,
133+
table_names: &[(SupportedColumnStructures, TableName)],
134134
structure: SupportedColumnStructures,
135135
) -> Vec<TableName> {
136136
table_names
137-
.into_iter()
137+
.iter()
138138
.filter_map(|(s, t)| if *s == structure { Some(t) } else { None })
139139
.cloned()
140140
.collect()
@@ -286,19 +286,19 @@ fn load_column_structure_data(
286286
DocConfig::NoDocComments => None,
287287
DocConfig::OnlyDatabaseComments
288288
| DocConfig::DatabaseCommentsFallbackToAutoGeneratedDocComment => {
289-
get_table_comment(connection, &name)?
289+
get_table_comment(connection, name)?
290290
}
291291
};
292292

293-
get_column_information(connection, &name, &config.column_sorting)?
293+
get_column_information(connection, name, &config.column_sorting)?
294294
.into_iter()
295295
.map(|c| {
296296
let default_pk = vec![];
297297
let ty = determine_column_type(
298298
&c,
299299
connection,
300-
&name,
301-
primary_key.unwrap_or_else(|| &default_pk),
300+
name,
301+
primary_key.unwrap_or(&default_pk),
302302
config,
303303
)?;
304304

diesel_cli/src/infer_schema_internals/information_schema.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -177,7 +177,7 @@ where
177177
Ok(table_names
178178
.into_iter()
179179
.map(|(name, tpy)| {
180-
let tpy = SupportedColumnStructures::from_str(&tpy).unwrap();
180+
let tpy = SupportedColumnStructures::from_str(&tpy).expect("This should never happen.");
181181
let data = TableName {
182182
rust_name: inference::rust_name_for_sql_name(&name),
183183
sql_name: name,

diesel_cli/src/infer_schema_internals/sqlite.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ pub fn load_table_names(
5050
.into_iter()
5151
.map(|table| {
5252
(
53-
SupportedColumnStructures::TABLE,
53+
SupportedColumnStructures::Table,
5454
TableName::from_name(table),
5555
)
5656
});
@@ -62,7 +62,7 @@ pub fn load_table_names(
6262
.order(name)
6363
.load::<String>(connection)?
6464
.into_iter()
65-
.map(|table| (SupportedColumnStructures::VIEW, TableName::from_name(table)));
65+
.map(|table| (SupportedColumnStructures::View, TableName::from_name(table)));
6666

6767
Ok(tables.chain(view).collect())
6868
}

diesel_cli/src/migrations/diff_schema.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,7 @@ pub fn generate_sql_based_on_diff_schema(
102102
for (structure, table) in tables_from_database {
103103
tracing::info!(?table, "Diff for existing table");
104104
match structure {
105-
SupportedColumnStructures::TABLE => {
105+
SupportedColumnStructures::Table => {
106106
let columns = crate::infer_schema_internals::load_table_data(
107107
&mut conn,
108108
table.clone(),
@@ -151,7 +151,7 @@ pub fn generate_sql_based_on_diff_schema(
151151
});
152152
}
153153
}
154-
SupportedColumnStructures::VIEW => {
154+
SupportedColumnStructures::View => {
155155
return Err(crate::errors::Error::UnsupportedFeature(
156156
"Views are not supported by --diff-schema yet".into(),
157157
));

diesel_cli/src/print_schema.rs

+4-4
Original file line numberDiff line numberDiff line change
@@ -159,7 +159,7 @@ pub fn output_schema(
159159
let foreign_keys = remove_unsafe_foreign_keys_for_codegen(
160160
connection,
161161
&foreign_keys,
162-
&filter_column_structure(&table_names, SupportedColumnStructures::TABLE),
162+
&filter_column_structure(&table_names, SupportedColumnStructures::Table),
163163
);
164164

165165
let mut out = String::new();
@@ -169,10 +169,10 @@ pub fn output_schema(
169169
let data = table_names
170170
.into_iter()
171171
.map(|(kind, t)| match kind {
172-
SupportedColumnStructures::TABLE => {
172+
SupportedColumnStructures::Table => {
173173
Ok(ColumnData::Table(load_table_data(connection, t, config)?))
174174
}
175-
SupportedColumnStructures::VIEW => {
175+
SupportedColumnStructures::View => {
176176
Ok(ColumnData::View(load_view_data(connection, t, config)?))
177177
}
178178
})
@@ -660,7 +660,7 @@ impl<'a> Display for ColumnStructureDefinition<'a> {
660660
out,
661661
"{}",
662662
ColumnDefinitions {
663-
columns: &self.table.columns(),
663+
columns: self.table.columns(),
664664
with_docs: self.with_docs,
665665
table_full_sql_name: &full_sql_name,
666666
custom_type_overrides: self.custom_type_overrides

0 commit comments

Comments
 (0)