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