From 71c35d4dfddc89cfdd8f67bdc4c5d4e701a355e8 Mon Sep 17 00:00:00 2001 From: Ilya Date: Wed, 20 Sep 2023 04:31:11 +0300 Subject: [PATCH] Add support for == operator for Sqlite (#970) --- src/tokenizer.rs | 1 + tests/sqlparser_sqlite.rs | 8 ++++++++ 2 files changed, 9 insertions(+) diff --git a/src/tokenizer.rs b/src/tokenizer.rs index 1b1b1e96c..175b5d3b1 100644 --- a/src/tokenizer.rs +++ b/src/tokenizer.rs @@ -885,6 +885,7 @@ impl<'a> Tokenizer<'a> { chars.next(); // consume match chars.peek() { Some('>') => self.consume_and_return(chars, Token::RArrow), + Some('=') => self.consume_and_return(chars, Token::DoubleEq), _ => Ok(Some(Token::Eq)), } } diff --git a/tests/sqlparser_sqlite.rs b/tests/sqlparser_sqlite.rs index 8f6cc7572..fd7a22461 100644 --- a/tests/sqlparser_sqlite.rs +++ b/tests/sqlparser_sqlite.rs @@ -61,6 +61,14 @@ fn parse_create_virtual_table() { sqlite_and_generic().verified_stmt(sql); } +#[test] +fn double_equality_operator() { + // Sqlite supports this operator: https://www.sqlite.org/lang_expr.html#binaryops + let input = "SELECT a==b FROM t"; + let expected = "SELECT a = b FROM t"; + let _ = sqlite_and_generic().one_statement_parses_to(input, expected); +} + #[test] fn parse_create_table_auto_increment() { let sql = "CREATE TABLE foo (bar INT PRIMARY KEY AUTOINCREMENT)";