Skip to main content

sqlparser/dialect/
oracle.rs

1// Licensed to the Apache Software Foundation (ASF) under one
2// or more contributor license agreements.  See the NOTICE file
3// distributed with this work for additional information
4// regarding copyright ownership.  The ASF licenses this file
5// to you under the Apache License, Version 2.0 (the
6// "License"); you may not use this file except in compliance
7// with the License.  You may obtain a copy of the License at
8//
9//   http://www.apache.org/licenses/LICENSE-2.0
10//
11// Unless required by applicable law or agreed to in writing,
12// software distributed under the License is distributed on an
13// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
14// KIND, either express or implied.  See the License for the
15// specific language governing permissions and limitations
16// under the License.
17
18use log::debug;
19
20use crate::{
21    parser::{Parser, ParserError},
22    tokenizer::Token,
23};
24
25use super::{Dialect, Precedence};
26
27/// A [`Dialect`] for [Oracle Databases](https://docs.oracle.com/en/database/oracle/oracle-database/21/sqlrf/index.html)
28#[derive(Debug)]
29pub struct OracleDialect;
30
31impl Dialect for OracleDialect {
32    // ~ appears not to be called anywhere
33    fn identifier_quote_style(&self, _identifier: &str) -> Option<char> {
34        Some('"')
35    }
36
37    fn is_delimited_identifier_start(&self, ch: char) -> bool {
38        ch == '"'
39    }
40
41    fn is_identifier_start(&self, ch: char) -> bool {
42        ch.is_alphabetic()
43    }
44
45    fn is_identifier_part(&self, ch: char) -> bool {
46        ch.is_alphanumeric() || ch == '_' || ch == '$' || ch == '#' || ch == '@'
47    }
48
49    fn supports_outer_join_operator(&self) -> bool {
50        true
51    }
52
53    fn supports_connect_by(&self) -> bool {
54        true
55    }
56
57    fn supports_execute_immediate(&self) -> bool {
58        true
59    }
60
61    fn supports_match_recognize(&self) -> bool {
62        true
63    }
64
65    fn supports_window_function_null_treatment_arg(&self) -> bool {
66        true
67    }
68
69    fn supports_boolean_literals(&self) -> bool {
70        false
71    }
72
73    fn supports_comment_on(&self) -> bool {
74        true
75    }
76
77    fn supports_create_table_select(&self) -> bool {
78        true
79    }
80
81    fn supports_set_stmt_without_operator(&self) -> bool {
82        true
83    }
84
85    fn get_next_precedence(&self, parser: &Parser) -> Option<Result<u8, ParserError>> {
86        let t = parser.peek_token();
87        debug!("get_next_precedence() {t:?}");
88
89        match t.token {
90            Token::StringConcat => Some(Ok(self.prec_value(Precedence::PlusMinus))),
91            _ => None,
92        }
93    }
94
95    fn supports_group_by_expr(&self) -> bool {
96        true
97    }
98
99    fn supports_quote_delimited_string(&self) -> bool {
100        true
101    }
102}