cargo clippy
This commit is contained in:
parent
ca56f27909
commit
e852a09498
2
.github/workflows/rust.yml
vendored
2
.github/workflows/rust.yml
vendored
@ -27,7 +27,7 @@ jobs:
|
||||
- uses: actions-rs/clippy-check@v1
|
||||
with:
|
||||
token: ${{ secrets.GITHUB_TOKEN }}
|
||||
args: --all-targets
|
||||
args: --all-targets --all
|
||||
|
||||
compile-sqlite:
|
||||
name: Compile SQLite
|
||||
|
@ -119,33 +119,18 @@ impl From<&ColumnDef> for Column {
|
||||
Some(ty) => ty.clone(),
|
||||
None => panic!("ColumnType should not be empty"),
|
||||
};
|
||||
let auto_increments: Vec<bool> = col_def
|
||||
let auto_increment = col_def
|
||||
.get_column_spec()
|
||||
.iter()
|
||||
.filter_map(|spec| match spec {
|
||||
ColumnSpec::AutoIncrement => Some(true),
|
||||
_ => None,
|
||||
})
|
||||
.collect();
|
||||
let auto_increment = !auto_increments.is_empty();
|
||||
let not_nulls: Vec<bool> = col_def
|
||||
.any(|spec| matches!(spec, ColumnSpec::AutoIncrement));
|
||||
let not_null = col_def
|
||||
.get_column_spec()
|
||||
.iter()
|
||||
.filter_map(|spec| match spec {
|
||||
ColumnSpec::NotNull => Some(true),
|
||||
_ => None,
|
||||
})
|
||||
.collect();
|
||||
let not_null = !not_nulls.is_empty();
|
||||
let uniques: Vec<bool> = col_def
|
||||
.any(|spec| matches!(spec, ColumnSpec::NotNull));
|
||||
let unique = col_def
|
||||
.get_column_spec()
|
||||
.iter()
|
||||
.filter_map(|spec| match spec {
|
||||
ColumnSpec::UniqueKey => Some(true),
|
||||
_ => None,
|
||||
})
|
||||
.collect();
|
||||
let unique = !uniques.is_empty();
|
||||
.any(|spec| matches!(spec, ColumnSpec::UniqueKey));
|
||||
Self {
|
||||
name,
|
||||
col_type,
|
||||
|
@ -34,11 +34,6 @@ impl EntityTransformer {
|
||||
.iter()
|
||||
.map(|col_def| col_def.into())
|
||||
.collect();
|
||||
let unique_columns: Vec<String> = columns
|
||||
.iter()
|
||||
.filter(|col| col.unique)
|
||||
.map(|col| col.name.clone())
|
||||
.collect();
|
||||
let relations = table_create
|
||||
.get_foreign_key_create_stmts()
|
||||
.iter()
|
||||
@ -85,8 +80,13 @@ impl EntityTransformer {
|
||||
false => {
|
||||
let ref_table = rel.ref_table;
|
||||
let mut unique = true;
|
||||
for col in rel.columns.iter() {
|
||||
if !unique_columns.contains(col) {
|
||||
for column in rel.columns.iter() {
|
||||
if !entity
|
||||
.columns
|
||||
.iter()
|
||||
.filter(|col| col.unique)
|
||||
.any(|col| col.name.as_str() == column)
|
||||
{
|
||||
unique = false;
|
||||
break;
|
||||
}
|
||||
|
@ -308,7 +308,7 @@ mod tests {
|
||||
use sea_query::ColumnType;
|
||||
use std::io::{self, BufRead, BufReader};
|
||||
|
||||
const ENTITY_FILES: [&'static str; 5] = [
|
||||
const ENTITY_FILES: [&str; 5] = [
|
||||
include_str!("../../tests/entity/cake.rs"),
|
||||
include_str!("../../tests/entity/cake_filling.rs"),
|
||||
include_str!("../../tests/entity/filling.rs"),
|
||||
|
Loading…
x
Reference in New Issue
Block a user