Skip to content

Commit 4005381

Browse files
committed
Add support for PostgreSQL/Redshift geometric operators
1 parent fdc90cf commit 4005381

File tree

3 files changed

+9
-7
lines changed

3 files changed

+9
-7
lines changed

src/ast/data_type.rs

+1
Original file line numberDiff line numberDiff line change
@@ -927,6 +927,7 @@ pub enum ArrayElemTypeDef {
927927
/// [Postgres]: https://www.postgresql.org/docs/9.5/functions-geometry.html
928928
#[derive(Debug, Copy, Clone, PartialEq, Eq, Hash, PartialOrd, Ord)]
929929
#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
930+
#[cfg_attr(feature = "visitor", derive(Visit, VisitMut))]
930931
pub enum GeometricTypeKind {
931932
Point,
932933
Line,

src/parser/mod.rs

+7-6
Original file line numberDiff line numberDiff line change
@@ -1222,7 +1222,6 @@ impl<'a> Parser<'a> {
12221222
Keyword::POLYGON => Ok(Some(self.parse_geometric_type(GeometricTypeKind::Polygon)?)),
12231223
_ => Ok(None),
12241224
},
1225-
12261225
_ => Ok(None),
12271226
}
12281227
}
@@ -3141,10 +3140,14 @@ impl<'a> Parser<'a> {
31413140
Token::QuestionMarkDash if self.dialect.supports_geometric_types() => {
31423141
Some(BinaryOperator::QuestionDash)
31433142
}
3144-
Token::AmpersandLeftAngleBracketVerticalBar if self.dialect.supports_geometric_types() => {
3143+
Token::AmpersandLeftAngleBracketVerticalBar
3144+
if self.dialect.supports_geometric_types() =>
3145+
{
31453146
Some(BinaryOperator::AndLtPipe)
31463147
}
3147-
Token::VerticalBarAmpersandRightAngleBracket if self.dialect.supports_geometric_types() => {
3148+
Token::VerticalBarAmpersandRightAngleBracket
3149+
if self.dialect.supports_geometric_types() =>
3150+
{
31483151
Some(BinaryOperator::PipeAndGt)
31493152
}
31503153
Token::TwoWayArrow if self.dialect.supports_geometric_types() => {
@@ -3174,9 +3177,7 @@ impl<'a> Parser<'a> {
31743177
Token::VerticalBarShiftRight if self.dialect.supports_geometric_types() => {
31753178
Some(BinaryOperator::PipeGtGt)
31763179
}
3177-
Token::AtSign if self.dialect.supports_geometric_types() => {
3178-
Some(BinaryOperator::At)
3179-
}
3180+
Token::AtSign if self.dialect.supports_geometric_types() => Some(BinaryOperator::At),
31803181

31813182
Token::Word(w) => match w.keyword {
31823183
Keyword::AND => Some(BinaryOperator::And),

src/tokenizer.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1704,7 +1704,7 @@ impl<'a> Tokenizer<'a> {
17041704
(None, Some(tok)) => Ok(Some(tok)),
17051705
(None, None) => self.tokenizer_error(
17061706
chars.location(),
1707-
&format!("Expected a valid binary operator after '{}'", prefix),
1707+
format!("Expected a valid binary operator after '{}'", prefix),
17081708
),
17091709
}
17101710
}

0 commit comments

Comments
 (0)