Use OperatorName newtype (#631)

Got confused by more `String` types, turns out we already had more
accurate types for these things. Functional no-op.

V3_GIT_ORIGIN_REV_ID: a9c73024ab23233a73934bb2cd3741b3b4d7a378
This commit is contained in:
Daniel Harvey 2024-05-29 20:35:29 +01:00 committed by hasura-bot
parent 7bc6755686
commit 8238613e68
3 changed files with 11 additions and 8 deletions

View File

@ -11,7 +11,10 @@ use crate::types::subgraph::Qualified;
use crate::helpers::type_mappings;
use lang_graphql::ast::common as ast;
use open_dds::{data_connector::DataConnectorName, types::CustomTypeName};
use open_dds::{
data_connector::DataConnectorName,
types::{CustomTypeName, OperatorName},
};
use std::collections::{BTreeMap, BTreeSet};
pub use types::{
BooleanExpressionGraphqlConfig, BooleanExpressionInfo, BooleanExpressionsOutput,
@ -318,7 +321,7 @@ pub fn resolve_boolean_expression_info(
scalar_type_info.scalar_type.comparison_operators.iter()
{
operators.insert(
op_name.clone(),
OperatorName(op_name.clone()),
resolve_ndc_type(
data_connector_name,
&get_argument_type(op_definition, &field_mapping.column_type),
@ -341,7 +344,7 @@ pub fn resolve_boolean_expression_info(
is_null_operator_name: filter_graphql_config
.operator_names
.is_null
.to_string(),
.clone(),
},
);
};

View File

@ -8,7 +8,7 @@ use std::collections::BTreeSet;
use open_dds::{
data_connector::{DataConnectorName, DataConnectorObjectType},
types::{CustomTypeName, FieldName},
types::{CustomTypeName, FieldName, OperatorName},
};
use serde::{Deserialize, Serialize};
@ -44,8 +44,8 @@ pub struct ComparisonExpressionInfo {
pub scalar_type_name: String,
pub type_name: ast::TypeName,
pub ndc_column: String,
pub operators: BTreeMap<String, QualifiedTypeReference>,
pub is_null_operator_name: String,
pub operators: BTreeMap<OperatorName, QualifiedTypeReference>,
pub is_null_operator_name: ast::Name,
}
#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, Eq)]

View File

@ -263,7 +263,7 @@ fn get_scalar_comparison_input_type(
let graphql_type_name = comparison_expression.type_name.clone();
let mut operators = Vec::new();
for (op_name, input_type) in &comparison_expression.operators {
let op_name = mk_name(op_name.as_str())?;
let op_name = mk_name(op_name.0.as_str())?;
operators.push((op_name, input_type.clone()))
}
Ok(
@ -271,7 +271,7 @@ fn get_scalar_comparison_input_type(
scalar_type_name: comparison_expression.scalar_type_name.clone(),
graphql_type_name,
operators,
is_null_operator_name: mk_name(&comparison_expression.is_null_operator_name)?,
is_null_operator_name: comparison_expression.is_null_operator_name.clone(),
}),
)
}