Skip to content
This repository was archived by the owner on Dec 25, 2019. It is now read-only.

Commit 2b70cac

Browse files
committed
Fix ast::Ident merge skew
Various Materialize-only tests (i.e., tests that were not present upstream) need to be adjusted for the new world, where ast::Ident is not an alias for a string but a full-fledged type.
1 parent 55f78f8 commit 2b70cac

File tree

2 files changed

+11
-11
lines changed

2 files changed

+11
-11
lines changed

src/ast/visit_macro.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1624,22 +1624,22 @@ mod tests {
16241624
#[test]
16251625
fn test_basic_visitor() -> Result<(), Box<dyn Error>> {
16261626
struct Visitor<'a> {
1627-
seen_idents: Vec<&'a Ident>,
1627+
seen_idents: Vec<&'a str>,
16281628
}
16291629

16301630
impl<'a> Visit<'a> for Visitor<'a> {
16311631
fn visit_ident(&mut self, ident: &'a Ident) {
1632-
self.seen_idents.push(ident);
1632+
self.seen_idents.push(&ident.value);
16331633
}
16341634
}
16351635

16361636
struct VisitorMut<'a> {
1637-
seen_idents: Vec<&'a mut Ident>,
1637+
seen_idents: Vec<&'a str>,
16381638
}
16391639

16401640
impl<'a> VisitMut<'a> for VisitorMut<'a> {
16411641
fn visit_ident(&mut self, ident: &'a mut Ident) {
1642-
self.seen_idents.push(ident);
1642+
self.seen_idents.push(&ident.value);
16431643
}
16441644
}
16451645

tests/sqlparser_common.rs

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2743,8 +2743,8 @@ fn parse_create_index() {
27432743
assert_eq!(
27442744
key_parts,
27452745
vec![
2746-
Expr::Identifier("a".to_string()),
2747-
Expr::Identifier("b".to_string())
2746+
Expr::Identifier(Ident::new("a")),
2747+
Expr::Identifier(Ident::new("b"))
27482748
]
27492749
);
27502750
}
@@ -2763,14 +2763,14 @@ fn parse_create_index() {
27632763
assert_matches!(key_parts[0], Expr::Function(..));
27642764
assert_eq!(
27652765
key_parts[1],
2766-
Expr::IsNotNull(Box::new(Expr::Identifier("a".to_string())))
2766+
Expr::IsNotNull(Box::new(Expr::Identifier(Ident::new("a"))))
27672767
);
27682768
if let Expr::Nested(expr) = &key_parts[2] {
27692769
assert_matches!(**expr, Expr::Exists(..));
27702770
} else {
27712771
assert!(false);
27722772
}
2773-
assert_eq!(key_parts[3], Expr::Identifier("delta".to_string()));
2773+
assert_eq!(key_parts[3], Expr::Identifier(Ident::new("delta")));
27742774
}
27752775
_ => assert!(false),
27762776
}
@@ -2787,7 +2787,7 @@ fn parse_create_index() {
27872787
assert_eq!(
27882788
key_parts,
27892789
vec![Expr::Nested(Box::new(Expr::BinaryOp {
2790-
left: Box::new(Expr::Identifier("col".to_string())),
2790+
left: Box::new(Expr::Identifier(Ident::new("col"))),
27912791
op: BinaryOperator::Plus,
27922792
right: Box::new(Expr::Value(Value::Number("1".to_string())))
27932793
}))],
@@ -2807,8 +2807,8 @@ fn parse_create_index() {
28072807
assert_eq!(
28082808
key_parts,
28092809
vec![Expr::CompoundIdentifier(vec![
2810-
"alpha".to_string(),
2811-
"omega".to_string()
2810+
Ident::new("alpha"),
2811+
Ident::new("omega"),
28122812
])],
28132813
);
28142814
}

0 commit comments

Comments
 (0)