Skip to content

Commit 95d9f8d

Browse files
committed
chore: fmt & clippy
1 parent c27ac3c commit 95d9f8d

4 files changed

Lines changed: 46 additions & 46 deletions

File tree

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,30 +1,30 @@
11
#[macro_export]
22
macro_rules! to_kind {
33
(NATIVE) => {
4-
crate::Kind::Native
4+
$crate::Kind::Native
55
};
66
($generic:ident) => {
7-
crate::Kind::Generic(stringify!($generic))
7+
$crate::Kind::Generic(stringify!($generic))
88
};
99
}
1010

1111
#[macro_export]
1212
macro_rules! sql_fn_args {
1313
(()) => { vec![] };
1414

15-
(($arg:ident)) => { vec![crate::to_kind!($arg)] };
15+
(($arg:ident)) => { vec![$crate::to_kind!($arg)] };
1616

1717
(($arg:ident $(,$rest:ident)*)) => {
18-
vec![crate::to_kind!($arg) $(,crate::to_kind!($rest))*]
18+
vec![$crate::to_kind!($arg) $(, $crate::to_kind!($rest))*]
1919
};
2020
}
2121

2222
#[macro_export]
2323
macro_rules! sql_fn {
2424
($name:ident $args:tt -> $return_kind:ident) => {
25-
crate::SqlFunction::new(
25+
$crate::SqlFunction::new(
2626
stringify!($name),
27-
FunctionSig::new(crate::sql_fn_args!($args), crate::to_kind!($return_kind)),
27+
FunctionSig::new($crate::sql_fn_args!($args), $crate::to_kind!($return_kind)),
2828
)
2929
};
30-
}
30+
}

packages/eql-mapper/src/inference/sql_functions.rs

Lines changed: 28 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,6 @@ impl FunctionSig {
110110
};
111111

112112
let args: Vec<Arc<Type>> = (0..arg_count)
113-
.into_iter()
114113
.map(|_| Arc::new(Type::any_native()))
115114
.collect();
116115

@@ -134,7 +133,7 @@ impl InstantiatedSig {
134133

135134
match &function.args {
136135
FunctionArguments::None => {
137-
if self.args.len() == 0 {
136+
if self.args.is_empty() {
138137
Ok(())
139138
} else {
140139
Err(TypeError::Conflict(format!(
@@ -197,38 +196,39 @@ impl From<&str> for CompoundIdent {
197196
impl From<&Vec<Ident>> for CompoundIdent {
198197
fn from(value: &Vec<Ident>) -> Self {
199198
let mut idents = Vec1::<SqlIdent<Ident>>::new(SqlIdent(value[0].clone()));
200-
idents.extend(value[1..].into_iter().cloned().map(SqlIdent));
199+
idents.extend(value[1..].iter().cloned().map(SqlIdent));
201200
CompoundIdent(idents)
202201
}
203202
}
204203

205204
/// SQL functions that are handled with special case type checking rules.
206-
static SQL_FUNCTION_SIGNATURES: LazyLock<HashMap<CompoundIdent, Vec<FunctionSig>>> = LazyLock::new(|| {
207-
// Notation: a single uppercase letter denotes an unknown type. Matching letters in a signature will be assigned
208-
// *the same type variable* and thus must resolve to the same type. (🙏 Haskell)
209-
//
210-
// Eventually we should type check EQL types against their configured indexes instead of leaving that to the EQL
211-
// extension in the database. I can imagine supporting type bounds in signatures here, such as: `T: Eq`
212-
let sql_fns = vec![
213-
sql_fn!(count(T) -> NATIVE),
214-
sql_fn!(min(T) -> T),
215-
sql_fn!(max(T) -> T),
216-
sql_fn!(jsonb_path_query(T, T) -> T),
217-
sql_fn!(jsonb_path_query_first(T, T) -> T),
218-
sql_fn!(jsonb_path_exists(T, T) -> T),
219-
];
220-
221-
let mut sql_fns_by_name: HashMap<CompoundIdent, Vec<FunctionSig>> = HashMap::new();
222-
223-
for (key, chunk) in &sql_fns.into_iter().chunk_by(|sql_fn| sql_fn.0.clone()) {
224-
sql_fns_by_name.insert(
225-
key.clone(),
226-
chunk.into_iter().map(|sql_fn| sql_fn.1).collect(),
227-
);
228-
}
205+
static SQL_FUNCTION_SIGNATURES: LazyLock<HashMap<CompoundIdent, Vec<FunctionSig>>> =
206+
LazyLock::new(|| {
207+
// Notation: a single uppercase letter denotes an unknown type. Matching letters in a signature will be assigned
208+
// *the same type variable* and thus must resolve to the same type. (🙏 Haskell)
209+
//
210+
// Eventually we should type check EQL types against their configured indexes instead of leaving that to the EQL
211+
// extension in the database. I can imagine supporting type bounds in signatures here, such as: `T: Eq`
212+
let sql_fns = vec![
213+
sql_fn!(count(T) -> NATIVE),
214+
sql_fn!(min(T) -> T),
215+
sql_fn!(max(T) -> T),
216+
sql_fn!(jsonb_path_query(T, T) -> T),
217+
sql_fn!(jsonb_path_query_first(T, T) -> T),
218+
sql_fn!(jsonb_path_exists(T, T) -> T),
219+
];
220+
221+
let mut sql_fns_by_name: HashMap<CompoundIdent, Vec<FunctionSig>> = HashMap::new();
222+
223+
for (key, chunk) in &sql_fns.into_iter().chunk_by(|sql_fn| sql_fn.0.clone()) {
224+
sql_fns_by_name.insert(
225+
key.clone(),
226+
chunk.into_iter().map(|sql_fn| sql_fn.1).collect(),
227+
);
228+
}
229229

230-
sql_fns_by_name
231-
});
230+
sql_fns_by_name
231+
});
232232

233233
pub(crate) fn get_type_signature_for_special_cased_sql_function(
234234
fn_name: &CompoundIdent,

packages/eql-mapper/src/model/sql_ident.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -110,20 +110,20 @@ impl Hash for SqlIdent<&Ident> {
110110
state.write_u8(1);
111111
state.write_u32(ch as u32);
112112
state.write(self.0.value.as_bytes());
113-
},
113+
}
114114
None => {
115115
state.write_u8(0);
116-
for ch in self.0.value.chars().map(|ch| ch.to_lowercase()).flatten() {
116+
for ch in self.0.value.chars().flat_map(|ch| ch.to_lowercase()) {
117117
state.write_u32(ch as u32);
118118
}
119-
},
119+
}
120120
}
121121
}
122122
}
123123

124124
impl Hash for SqlIdent<Ident> {
125125
fn hash<H: Hasher>(&self, state: &mut H) {
126-
SqlIdent(&self.0).hash(state)
126+
SqlIdent(&self.0).hash(state)
127127
}
128128
}
129129

packages/eql-mapper/src/test_helpers.rs

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -46,12 +46,12 @@ pub(crate) fn get_node_key_of_json_selector<'ast>(
4646
.expect("could not find selector Value node")
4747
}
4848

49-
pub(crate) fn dummy_encrypted_json_selector<'ast>(
50-
statement: &'ast Statement,
49+
pub(crate) fn dummy_encrypted_json_selector(
50+
statement: &Statement,
5151
selector: Value,
52-
) -> HashMap<NodeKey<'ast>, ast::Value> {
52+
) -> HashMap<NodeKey<'_>, ast::Value> {
5353
if let Value::SingleQuotedString(s) = &selector {
54-
return HashMap::from_iter(vec![(
54+
HashMap::from_iter(vec![(
5555
get_node_key_of_json_selector(statement, &selector),
5656
ast::Value::SingleQuotedString(format!("<encrypted-selector({})>", s)),
5757
)])
@@ -61,10 +61,10 @@ pub(crate) fn dummy_encrypted_json_selector<'ast>(
6161
}
6262

6363
/// Utility for finding the [`NodeKey`] of a [`Value`] node in `statement` by providing a `matching` equal node to search for.
64-
pub(crate) fn find_nodekey_for_value_node<'ast>(
65-
statement: &'ast Statement,
64+
pub(crate) fn find_nodekey_for_value_node(
65+
statement: &Statement,
6666
matching: ast::Value,
67-
) -> Option<NodeKey<'ast>> {
67+
) -> Option<NodeKey<'_>> {
6868
struct FindNode<'ast> {
6969
needle: ast::Value,
7070
found: Option<NodeKey<'ast>>,

0 commit comments

Comments
 (0)