Skip to content

Commit

Permalink
Merge pull request #563 from supabase/fix_clippy_warnings
Browse files Browse the repository at this point in the history
fix clippy and other warnings
  • Loading branch information
olirice authored Sep 27, 2024
2 parents 78bcbdf + 6357f39 commit 22ff85c
Show file tree
Hide file tree
Showing 5 changed files with 23 additions and 48 deletions.
File renamed without changes.
2 changes: 1 addition & 1 deletion .github/workflows/pre-commit.yaml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
name: pre-commit
on:
pull_request:
push: { branches: master }
push: { branches: [master] }

jobs:
build:
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/test.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
name: tests
on:
pull_request:
push: { branches: master }
push: { branches: [master] }

jobs:
test:
Expand Down
20 changes: 1 addition & 19 deletions src/builder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,6 @@ use std::sync::Arc;

#[derive(Clone, Debug)]
pub struct InsertBuilder {
pub alias: String,

// args
pub objects: Vec<InsertRowBuilder>,

Expand Down Expand Up @@ -272,7 +270,6 @@ where
.name()
.ok_or("Encountered type without name in connection builder")?;
let field_map = field_map(&type_);
let alias = alias_or_name(query_field);

match &type_ {
__Type::InsertResponse(xtype) => {
Expand Down Expand Up @@ -320,7 +317,6 @@ where
}
}
Ok(InsertBuilder {
alias,
table: Arc::clone(&xtype.table),
objects,
selections: builder_fields,
Expand All @@ -335,8 +331,6 @@ where

#[derive(Clone, Debug)]
pub struct UpdateBuilder {
pub alias: String,

// args
pub filter: FilterBuilder,
pub set: SetBuilder,
Expand Down Expand Up @@ -438,7 +432,6 @@ where
.name()
.ok_or("Encountered type without name in update builder")?;
let field_map = field_map(&type_);
let alias = alias_or_name(query_field);

match &type_ {
__Type::UpdateResponse(xtype) => {
Expand Down Expand Up @@ -490,7 +483,6 @@ where
}
}
Ok(UpdateBuilder {
alias,
filter,
set,
at_most,
Expand All @@ -507,8 +499,6 @@ where

#[derive(Clone, Debug)]
pub struct DeleteBuilder {
pub alias: String,

// args
pub filter: FilterBuilder,
pub at_most: i64,
Expand Down Expand Up @@ -544,7 +534,6 @@ where
.name()
.ok_or("Encountered type without name in delete builder")?;
let field_map = field_map(&type_);
let alias = alias_or_name(query_field);

match &type_ {
__Type::DeleteResponse(xtype) => {
Expand Down Expand Up @@ -594,7 +583,6 @@ where
}
}
Ok(DeleteBuilder {
alias,
filter,
at_most,
table: Arc::clone(&xtype.table),
Expand All @@ -609,8 +597,6 @@ where
}

pub struct FunctionCallBuilder {
pub alias: String,

// metadata
pub function: Arc<Function>,

Expand Down Expand Up @@ -650,7 +636,6 @@ where
T::Value: Hash,
{
let type_ = field.type_().unmodified_type();
let alias = alias_or_name(query_field);

match &type_ {
__Type::FuncCallResponse(func_call_resp_type) => {
Expand Down Expand Up @@ -703,7 +688,6 @@ where
};

Ok(FunctionCallBuilder {
alias,
function: Arc::clone(&func_call_resp_type.function),
args_builder: args,
return_type_builder,
Expand Down Expand Up @@ -1311,7 +1295,7 @@ where
)?;
let _: Scalar = match field
.get_arg(arg_name)
.expect(&format!("failed to get {} argument", arg_name))
.unwrap_or_else(|| panic!("failed to get {} argument", arg_name))
.type_()
.unmodified_type()
{
Expand Down Expand Up @@ -1977,7 +1961,6 @@ pub struct __SchemaSelection {

#[derive(Clone)]
pub struct __SchemaBuilder {
pub schema: __Schema,
pub selections: Vec<__SchemaSelection>,
}

Expand Down Expand Up @@ -2618,7 +2601,6 @@ impl __Schema {
}

Ok(__SchemaBuilder {
schema: self.clone(),
selections: builder_fields,
})
}
Expand Down
47 changes: 20 additions & 27 deletions src/graphql.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ use cached::SizedCache;
use itertools::Itertools;
use serde::Serialize;
use std::collections::{HashMap, HashSet};
use std::fmt::Display;
use std::ops::Deref;
use std::sync::Arc;

Expand Down Expand Up @@ -345,15 +346,6 @@ pub trait ___Field {
fn deprecation_reason(&self) -> Option<String> {
None
}

fn arg_map(&self) -> HashMap<String, __InputValue> {
let mut amap = HashMap::new();
let args = self.args();
for arg in args {
amap.insert(arg.name_.clone(), arg.clone());
}
amap
}
}

#[derive(Clone, Debug)]
Expand Down Expand Up @@ -528,8 +520,10 @@ pub enum __Type {
// Constant
PageInfo(PageInfoType),
// Introspection
#[allow(clippy::enum_variant_names)]
__TypeKind(__TypeKindType),
__Schema(__SchemaType),
#[allow(clippy::enum_variant_names)]
__Type(__TypeType),
__Field(__FieldType),
__InputValue(__InputValueType),
Expand Down Expand Up @@ -3342,9 +3336,9 @@ pub enum FilterOp {
Overlap,
}

impl ToString for FilterOp {
fn to_string(&self) -> String {
match self {
impl Display for FilterOp {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
let res = match self {
Self::Equal => "eq",
Self::NotEqual => "neq",
Self::LessThan => "lt",
Expand All @@ -3361,8 +3355,8 @@ impl ToString for FilterOp {
Self::Contains => "contains",
Self::ContainedBy => "containedBy",
Self::Overlap => "overlaps",
}
.to_string()
};
write!(f, "{res}")
}
}

Expand Down Expand Up @@ -3604,7 +3598,7 @@ impl ___Type for FilterTypeType {
]
}
FilterableType::List(list_type) => {
let supported_ops = vec![
let supported_ops = [
FilterOp::Contains,
FilterOp::ContainedBy,
FilterOp::Equal,
Expand Down Expand Up @@ -3717,7 +3711,7 @@ impl ___Type for FilterEntityType {
}),
__Type::List(l) => match l.type_.nullable_type() {
// Only non-json scalars are supported in list types
__Type::Scalar(s) => match s {
__Type::Scalar(
Scalar::Int
| Scalar::Float
| Scalar::String(_)
Expand All @@ -3727,18 +3721,17 @@ impl ___Type for FilterEntityType {
| Scalar::BigFloat
| Scalar::Time
| Scalar::Date
| Scalar::Datetime => Some(__InputValue {
name_: column_graphql_name,
type_: __Type::FilterType(FilterTypeType {
entity: FilterableType::List(l),
schema: Arc::clone(&self.schema),
}),
description: None,
default_value: None,
sql_type: Some(NodeSQLType::Column(Arc::clone(col))),
| Scalar::Datetime,
) => Some(__InputValue {
name_: column_graphql_name,
type_: __Type::FilterType(FilterTypeType {
entity: FilterableType::List(l),
schema: Arc::clone(&self.schema),
}),
_ => None,
},
description: None,
default_value: None,
sql_type: Some(NodeSQLType::Column(Arc::clone(col))),
}),
_ => None,
},
_ => None,
Expand Down

0 comments on commit 22ff85c

Please sign in to comment.