uqa_sql/schema/
identity_lookup.rs1use super::ColumnIdentity;
10use std::{
11 borrow::Borrow,
12 hash::{Hash, Hasher},
13};
14
15pub(super) trait ColumnKey {
16 fn parts(&self) -> (Option<&str>, &str);
17}
18
19impl ColumnKey for ColumnIdentity {
20 fn parts(&self) -> (Option<&str>, &str) {
21 (self.qualifier(), self.column())
22 }
23}
24
25impl ColumnKey for (Option<&str>, &str) {
26 fn parts(&self) -> (Option<&str>, &str) {
27 *self
28 }
29}
30
31impl<'a> Borrow<dyn ColumnKey + 'a> for ColumnIdentity {
32 fn borrow(&self) -> &(dyn ColumnKey + 'a) {
33 self
34 }
35}
36
37impl PartialEq for dyn ColumnKey + '_ {
38 fn eq(&self, other: &Self) -> bool {
39 self.parts() == other.parts()
40 }
41}
42
43impl Eq for dyn ColumnKey + '_ {}
44
45impl Hash for dyn ColumnKey + '_ {
46 fn hash<H: Hasher>(&self, state: &mut H) {
47 let (qualifier, column) = self.parts();
48 qualifier.hash(state);
49 column.hash(state);
50 }
51}
52
53#[cfg(test)]
54mod tests;